ImageDev

SigmaFilter2d

Performs an adaptive smoothing of a two-dimensional image by excluding any aberrant pixels of a local averaging.

Access to parameter description

For an introduction to image filters: see Images Filtering.

This algorithm computes a local mean from each pixel neighborhood values. Pixel values far from the considered pixel intensity $I_c$ are excluded using a user threshold $\sigma$.
Only pixels verifying the following formula are kept for computation:
$$ I \in [I_c-2\sigma, I_c+2\sigma] $$ A user-defined population threshold allows the algorithm to switch between the formula above and a classical neighbor mean formula. This parameter avoids considering low populated neighborhoods for computation.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > sigmaFilter2d( std::shared_ptr< iolink::ImageView > inputImage, int32_t kernelSizeX, int32_t kernelSizeY, double standardDeviation, int32_t populationThreshold, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype.
sigma_filter_2d( input_image,
                 kernel_size_x = 3,
                 kernel_size_y = 3,
                 standard_deviation = 20,
                 population_threshold = 8,
                 output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
SigmaFilter2d( IOLink.ImageView inputImage,
               Int32 kernelSizeX = 3,
               Int32 kernelSizeY = 3,
               double standardDeviation = 20,
               Int32 populationThreshold = 8,
               IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name SigmaFilter2d

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
kernelSizeX
The horizontal kernel size in pixels (odd value). Int32 [3, 100] 3
input
kernelSizeY
The vertical kernel size in pixels (odd value). Int32 [3, 100] 3
input
standardDeviation
The intensity interval for retaining a pixel of the neighborhood. Float64 >0 20
input
populationThreshold
The population threshold. If the number of pixels selected by the formula is lower than this threshold, all pixels of the neighborhood are used for computing the mean. Int32 >=0 8
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" );

SigmaFilter2d sigmaFilter2dAlgo;
sigmaFilter2dAlgo.setInputImage( polystyrene );
sigmaFilter2dAlgo.setKernelSizeX( 3 );
sigmaFilter2dAlgo.setKernelSizeY( 3 );
sigmaFilter2dAlgo.setStandardDeviation( 20.0 );
sigmaFilter2dAlgo.setPopulationThreshold( 8 );
sigmaFilter2dAlgo.execute();

std::cout << "outputImage:" << sigmaFilter2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

sigma_filter_2d_algo = imagedev.SigmaFilter2d()
sigma_filter_2d_algo.input_image = polystyrene
sigma_filter_2d_algo.kernel_size_x = 3
sigma_filter_2d_algo.kernel_size_y = 3
sigma_filter_2d_algo.standard_deviation = 20.0
sigma_filter_2d_algo.population_threshold = 8
sigma_filter_2d_algo.execute()

print( "output_image:", str( sigma_filter_2d_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

SigmaFilter2d sigmaFilter2dAlgo = new SigmaFilter2d
{
    inputImage = polystyrene,
    kernelSizeX = 3,
    kernelSizeY = 3,
    standardDeviation = 20.0,
    populationThreshold = 8
};
sigmaFilter2dAlgo.Execute();

Console.WriteLine( "outputImage:" + sigmaFilter2dAlgo.outputImage.ToString() );

Function Examples

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

auto result = sigmaFilter2d( polystyrene, 3, 3, 20.0, 8 );

std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.sigma_filter_2d( polystyrene, 3, 3, 20.0, 8 )

print( "output_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.SigmaFilter2d( polystyrene, 3, 3, 20.0, 8 );

Console.WriteLine( "outputImage:" + result.ToString() );