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.
// Command constructor.Despeckle2d();/// Gets the inputImage parameter./// The input image.
std::shared_ptr< iolink::ImageView> inputImage()const;/// Sets the inputImage parameter./// The input image.void setInputImage( std::shared_ptr< iolink::ImageView> inputImage );/// Gets the kernelSizeX parameter./// Horizontal kernel size in pixels (odd value).int32_t kernelSizeX()const;/// Sets the kernelSizeX parameter./// Horizontal kernel size in pixels (odd value).void setKernelSizeX(constint32_t& kernelSizeX );/// Gets the kernelSizeY parameter./// Vertical kernel size in pixels (odd value).int32_t kernelSizeY()const;/// Sets the kernelSizeY parameter./// Vertical kernel size in pixels (odd value).void setKernelSizeY(constint32_t& kernelSizeY );/// Gets the thresholdFactor parameter./// The standard deviation threshold factor (must be a positive value).double thresholdFactor()const;/// Sets the thresholdFactor parameter./// The standard deviation threshold factor (must be a positive value).void setThresholdFactor(constdouble& thresholdFactor );/// Gets the outputImage parameter./// The output image. Its dimensions, type, and calibration are forced to the same values as the input.
std::shared_ptr< iolink::ImageView> outputImage()const;/// Sets the outputImage parameter./// The output image. Its dimensions, type, and calibration are forced to the same values as the input.void setOutputImage( std::shared_ptr< iolink::ImageView> outputImage );// Method to launch the command.void execute();
# Property of the inputImage parameter.Despeckle2d.input_image
# Property of the kernelSizeX parameter.Despeckle2d.kernel_size_x
# Property of the kernelSizeY parameter.Despeckle2d.kernel_size_y
# Property of the thresholdFactor parameter.Despeckle2d.threshold_factor
# Property of the outputImage parameter.Despeckle2d.output_image
// Method to launch the command.
execute()
// Command constructor.Despeckle2d()// Property of the inputImage parameter.Despeckle2d.inputImage
// Property of the kernelSizeX parameter.Despeckle2d.kernelSizeX
// Property of the kernelSizeY parameter.Despeckle2d.kernelSizeY
// Property of the thresholdFactor parameter.Despeckle2d.thresholdFactor
// Property of the outputImage parameter.Despeckle2d.outputImage
// Method to launch the command.Execute()
Parameters
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
Parameter Name
Description
Type
Supported Values
Default Value
input_image
The input image.
image
Binary, Label, Grayscale or Multispectral
None
kernel_size_x
Horizontal kernel size in pixels (odd value).
int32
[3, 100]
3
kernel_size_y
Vertical kernel size in pixels (odd value).
int32
[3, 100]
3
threshold_factor
The standard deviation threshold factor (must be a positive value).
float64
>0
1
output_image
The output image. Its dimensions, type, and calibration are forced to the same values as the input.
image
None
Parameter Name
Description
Type
Supported Values
Default Value
inputImage
The input image.
Image
Binary, Label, Grayscale or Multispectral
null
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.
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());