Processing math: 100%
ImageDev

Despeckle2d

Smooths a two-dimensional image by replacing any aberrant pixel values by their neighbors mean value.

Access to parameter description

For an introduction to image filters: see Images Filtering.

For each pixel of the input image, mean μ and standard deviation σ values of a rectangular neighbor window are computed.
The output image value is then given by: O(i,j)={μ(i,j) if λ×|I(i,j)μ(i,j)|>σ(i,j)I(i,j) otherwise
Where λ is a user-defined threshold factor on the distance of the current pixel gray level to the mean of its neighbors, relative to their standard deviation.
The greater λ is, the stronger the blur.

This filter gives good results in the case of impulse noise.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > despeckle2d( std::shared_ptr< iolink::ImageView > inputImage, int32_t kernelSizeX, int32_t kernelSizeY, double thresholdFactor, std::shared_ptr< iolink::ImageView > outputImage = NULL );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
kernelSizeX
Horizontal kernel size in pixels (odd value). Int32 [3, 100] 3
input
kernelSizeY
Vertical kernel size in pixels (odd value). Int32 [3, 100] 3
input
thresholdFactor
The standard deviation threshold factor (must be a positive value). Float64 >0 1
output
outputImage
The output image. Its dimensions, type, and calibration are forced to the same values as the input. Image nullptr

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

Despeckle2d despeckle2dAlgo;
despeckle2dAlgo.setInputImage( polystyrene );
despeckle2dAlgo.setKernelSizeX( 3 );
despeckle2dAlgo.setKernelSizeY( 3 );
despeckle2dAlgo.setThresholdFactor( 1.0 );
despeckle2dAlgo.execute();

std::cout << "outputImage:" << despeckle2dAlgo.outputImage()->toString();

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = despeckle2d( polystyrene, 3, 3, 1.0 );

std::cout << "outputImage:" << result->toString();