Temporal Noise Reduction¶
This code snippet shows how to perform noise reduction by temporal averaging.
C++¶
#include <eVision/EasyImage/EasyImage.h>
using namespace eVision;
// Images constructor
EImageBW16 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);
// Accumulation loop
int n;
for (n = 0; n < 10; n++)
{
// Acquire a new image into noisyImage
// ...
// Add this new noisy image into the accumulator
EasyImage::Oper(EArithmeticLogicOperation_Add, &noisyImage, &store, &store);
}
// Perform noise reduction
EasyImage::Oper(EArithmeticLogicOperation_Divide, &store, (EBW16)n, &cleanImage);
See also
C#¶
using eVision;
// Images constructor
EImageBW16 noisyImage = new EImageBW16();
EImageBW16 cleanImage = new EImageBW16();
// 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);
// Accumulation loop
int n;
for (n = 0; n < 10; n++)
{
// Acquire a new image into noisyImage
// ...
// Add this new noisy image into the accumulator
EasyImage.Oper(EArithmeticLogicOperation.Add, noisyImage, store, store);
}
// Perform noise reduction
bw16.Value = (byte)n;
EasyImage.Oper(EArithmeticLogicOperation.Divide, store, bw16, cleanImage);
See also
Python¶
import eVision
# Images constructor
noisyImage = eVision.EImageBW16()
cleanImage = eVision.EImageBW16()
# 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)
# Accumulation loop
n = 0
for n in range(10):
# Acquire a new image into noisyImage
# ...
# Add this new noisy image into the accumulator
eVision.EasyImage.Oper(eVision.EArithmeticLogicOperation.Add, noisyImage, store, store)
# Perform noise reduction
bw16.Value = n
eVision.EasyImage.Oper(eVision.EArithmeticLogicOperation.Divide, store, bw16, cleanImage)
See also