Despeckle2d
Smoothes 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 $\mu$ and standard deviation $\sigma$ values of a rectangular neighbor window are computed.
The output image value is then given by: $$ O(i,j)=\left\{\begin{array}{ll} \mu(i,j) & ~ \mbox{if} ~ \lambda \times |I(i,j)-\mu(i,j)| > \sigma(i,j)\\ I(i,j) & ~ \mbox{otherwise} \end{array}\right. $$
Where $\lambda$ 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 $\lambda$ is, the stronger the blur.
This filter gives good results in the case of impulse noise.
See also
Access to parameter description
For an introduction to image filters: see Images Filtering.
For each pixel of the input image, mean $\mu$ and standard deviation $\sigma$ values of a rectangular neighbor window are computed.
The output image value is then given by: $$ O(i,j)=\left\{\begin{array}{ll} \mu(i,j) & ~ \mbox{if} ~ \lambda \times |I(i,j)-\mu(i,j)| > \sigma(i,j)\\ I(i,j) & ~ \mbox{otherwise} \end{array}\right. $$
Where $\lambda$ 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 $\lambda$ is, the stronger the blur.
This filter gives good results in the case of impulse noise.
See also
Function Syntax
This function returns the outputImage output parameter.
// 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 );
This function returns the outputImage output parameter.
// Function prototype. despeckle_2d( input_image, kernel_size_x = 3, kernel_size_y = 3, threshold_factor = 1, output_image = None )
This function returns the outputImage output parameter.
// Function prototype. public static IOLink.ImageView Despeckle2d( IOLink.ImageView inputImage, Int32 kernelSizeX = 3, Int32 kernelSizeY = 3, double thresholdFactor = 1, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Class Name | Despeckle2d |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |
kernelSizeX |
Horizontal kernel size in pixels (odd value). | Int32 | [3, 100] | 3 | |
kernelSizeY |
Vertical kernel size in pixels (odd value). | Int32 | [3, 100] | 3 | |
thresholdFactor |
The standard deviation threshold factor (must be a positive value). | Float64 | >0 | 1 | |
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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) despeckle_2d_algo = imagedev.Despeckle2d() despeckle_2d_algo.input_image = polystyrene despeckle_2d_algo.kernel_size_x = 3 despeckle_2d_algo.kernel_size_y = 3 despeckle_2d_algo.threshold_factor = 1.0 despeckle_2d_algo.execute() print( "output_image:", str( despeckle_2d_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); Despeckle2d despeckle2dAlgo = new Despeckle2d { inputImage = polystyrene, kernelSizeX = 3, kernelSizeY = 3, thresholdFactor = 1.0 }; despeckle2dAlgo.Execute(); Console.WriteLine( "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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) result = imagedev.despeckle_2d( polystyrene, 3, 3, 1.0 ) print( "output_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); IOLink.ImageView result = Processing.Despeckle2d( polystyrene, 3, 3, 1.0 ); Console.WriteLine( "outputImage:" + result.ToString() );