This algorithm uses morphological operators to set the pixel value to the median for the defined
neighborhood. This filter is particularly effective for removing speckle noise and salt and pepper noise
(impulsive noise) without affecting edges.
The median filter usually works well with images containing non-Gaussian noise and/or very small artifacts.
It does not cause blurring to the same extent as the Box Filter, but takes longer
to execute.
The gray levels of all pixels of the considered neighborhood are sorted from the smallest value to the
largest one. The central pixel in the sort is then the median value (the value for which there are as
many lower gray levels as higher ones). The process can be iterated.
Considering the array:
[121715201416181914]
The sorted gray level values are: [12 14 14 15 16 17 18 19 20]. The median value is 16, and it is
assigned to the output pixel.
// Command constructor.MedianFilter2d();/// 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 kernelRadius parameter./// The half size of the structuring element. A square structuring element always has an odd side length (3x3, 5x5, etc.) which is defined by twice the kernel radius + 1.uint32_t kernelRadius()const;/// Sets the kernelRadius parameter./// The half size of the structuring element. A square structuring element always has an odd side length (3x3, 5x5, etc.) which is defined by twice the kernel radius + 1.void setKernelRadius(constuint32_t& kernelRadius );/// Gets the kernelMode parameter./// The structuring element shape and application mode.MedianFilter2d::KernelMode kernelMode()const;/// Sets the kernelMode parameter./// The structuring element shape and application mode.void setKernelMode(constMedianFilter2d::KernelMode& kernelMode );/// Gets the searchMode parameter./// Handles all types of method for finding the median.MedianFilter2d::SearchMode searchMode()const;/// Sets the searchMode parameter./// Handles all types of method for finding the median.void setSearchMode(constMedianFilter2d::SearchMode& searchMode );/// Gets the outputImage parameter./// The output image. Its dimensions and type 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 and type 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.MedianFilter2d.input_image
# Property of the kernelRadius parameter.MedianFilter2d.kernel_radius
# Property of the kernelMode parameter.MedianFilter2d.kernel_mode
# Property of the searchMode parameter.MedianFilter2d.search_mode
# Property of the outputImage parameter.MedianFilter2d.output_image
// Method to launch the command.
execute()
// Command constructor.MedianFilter2d()// Property of the inputImage parameter.MedianFilter2d.inputImage
// Property of the kernelRadius parameter.MedianFilter2d.kernelRadius
// Property of the kernelMode parameter.MedianFilter2d.kernelMode
// Property of the searchMode parameter.MedianFilter2d.searchMode
// Property of the outputImage parameter.MedianFilter2d.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
kernelRadius
The half size of the structuring element. A square structuring element always has an odd side length (3x3, 5x5, etc.) which is defined by twice the kernel radius + 1.
UInt32
>=1
3
kernelMode
The structuring element shape and application mode.
SQUARE
This mode considers a square structuring element of side length 2 x kernelRadius + 1 pixels.
DISK
This mode considers a disk structuring element of diameter 2 x kernelRadius + 1 pixels.
Enumeration
SQUARE
searchMode
Handles all types of method for finding the median.
AUTOMATIC
The algorithm automatically chooses the method to find the median value.
HISTOGRAM
The algorithm uses a histogram to find the median value.
SELECTION
The algorithm uses a shoting by selection to find the median value.
Enumeration
AUTOMATIC
outputImage
The output image. Its dimensions and type 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_radius
The half size of the structuring element. A square structuring element always has an odd side length (3x3, 5x5, etc.) which is defined by twice the kernel radius + 1.
uint32
>=1
3
kernel_mode
The structuring element shape and application mode.
SQUARE
This mode considers a square structuring element of side length 2 x kernelRadius + 1 pixels.
DISK
This mode considers a disk structuring element of diameter 2 x kernelRadius + 1 pixels.
enumeration
SQUARE
search_mode
Handles all types of method for finding the median.
AUTOMATIC
The algorithm automatically chooses the method to find the median value.
HISTOGRAM
The algorithm uses a histogram to find the median value.
SELECTION
The algorithm uses a shoting by selection to find the median value.
enumeration
AUTOMATIC
output_image
The output image. Its dimensions and type 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
kernelRadius
The half size of the structuring element. A square structuring element always has an odd side length (3x3, 5x5, etc.) which is defined by twice the kernel radius + 1.
UInt32
>=1
3
kernelMode
The structuring element shape and application mode.
SQUARE
This mode considers a square structuring element of side length 2 x kernelRadius + 1 pixels.
DISK
This mode considers a disk structuring element of diameter 2 x kernelRadius + 1 pixels.
Enumeration
SQUARE
searchMode
Handles all types of method for finding the median.
AUTOMATIC
The algorithm automatically chooses the method to find the median value.
HISTOGRAM
The algorithm uses a histogram to find the median value.
SELECTION
The algorithm uses a shoting by selection to find the median value.
Enumeration
AUTOMATIC
outputImage
The output image. Its dimensions and type are forced to the same values as the input.