Recursive Average

This code snippet shows how to perform noise reduction by recursive averaging.

C++

#include <eVision/EasyImage/EasyImage.h>
using namespace eVision;
// Images constructor
EImageBW8 noisyImage, cleanImage;
// 16 bits work image used as an accumulator
EImageBW16 store;
// ...
// All images must have the same size
cleanImage.SetSize(&noisyImage);
store.SetSize(&noisyImage);
// Clear the accumulator image
EasyImage::Oper(EArithmeticLogicOperation_Copy, (EBW16)0, &store);
// Prepare the transfer lookup table (reduction factor = 3)
EBW16Vector lut;
EasyImage::SetRecursiveAverageLUT(&lut, 3.f);
// Perform the noise reduction
EasyImage::RecursiveAverage(&noisyImage, &store, &cleanImage, &lut);

C#

using eVision;
// Images constructor
EImageBW8 noisyImage = new EImageBW8();
EImageBW8 cleanImage = new EImageBW8();
// 16 bits work image used as an accumulator
EImageBW16 store = new EImageBW16();
// ...
// All images must have the same size
cleanImage.SetSize(noisyImage);
store.SetSize(noisyImage);
// Clear the accumulator image
EBW16 bw16 = new EBW16(0);
EasyImage.Oper(EArithmeticLogicOperation.Copy, bw16, store);
// Prepare the transfer lookup table (reduction factor = 3)
EBW16Vector lut = new EBW16Vector();
EasyImage.SetRecursiveAverageLUT(lut, 3.0f);
// Perform the noise reduction
EasyImage.RecursiveAverage(noisyImage, store, cleanImage, lut);

Python

import eVision
# Images constructor
noisyImage = eVision.EImageBW8()
cleanImage = eVision.EImageBW8()
# 16 bits work image used as an accumulator
store = eVision.EImageBW16()
# ...
# All images must have the same size
cleanImage.SetSize(noisyImage)
store.SetSize(noisyImage)
# Clear the accumulator image
bw16 = eVision.EBW16(0)
eVision.EasyImage.Oper(eVision.EArithmeticLogicOperation.Copy, bw16, store)
# Prepare the transfer lookup table (reduction factor = 3)
lut = eVision.EBW16Vector()
eVision.EasyImage.SetRecursiveAverageLUT(lut, 3.0)
# Perform the noise reduction
eVision.EasyImage.RecursiveAverage(noisyImage, store, cleanImage, lut)