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.CudaMedianFilter2d();/// 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 tilingMode parameter./// The way to manage the GPU memory.CudaMedianFilter2d::TilingMode tilingMode()const;/// Sets the tilingMode parameter./// The way to manage the GPU memory.void setTilingMode(constCudaMedianFilter2d::TilingMode& tilingMode );/// Gets the tileSize parameter./// The tile width and height in pixels. This parameter is used only in USER_DEFINED tiling mode.
iolink::Vector2u32 tileSize()const;/// Sets the tileSize parameter./// The tile width and height in pixels. This parameter is used only in USER_DEFINED tiling mode.void setTileSize(const iolink::Vector2u32& tileSize );/// Gets the cudaContext parameter./// CUDA context information.CudaContext::Ptr cudaContext()const;/// Sets the cudaContext parameter./// CUDA context information.void setCudaContext(constCudaContext::Ptr& cudaContext );/// 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.CudaMedianFilter2d.input_image
# Property of the kernelRadius parameter.CudaMedianFilter2d.kernel_radius
# Property of the tilingMode parameter.CudaMedianFilter2d.tiling_mode
# Property of the tileSize parameter.CudaMedianFilter2d.tile_size
# Property of the cudaContext parameter.CudaMedianFilter2d.cuda_context
# Property of the outputImage parameter.CudaMedianFilter2d.output_image
// Method to launch the command.
execute()
// Command constructor.CudaMedianFilter2d()// Property of the inputImage parameter.CudaMedianFilter2d.inputImage
// Property of the kernelRadius parameter.CudaMedianFilter2d.kernelRadius
// Property of the tilingMode parameter.CudaMedianFilter2d.tilingMode
// Property of the tileSize parameter.CudaMedianFilter2d.tileSize
// Property of the cudaContext parameter.CudaMedianFilter2d.cudaContext
// Property of the outputImage parameter.CudaMedianFilter2d.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, 6]
3
tilingMode
The way to manage the GPU memory.
NONE
The entire input image is transferred to the GPU memory.
If the total input, intermediate and output data size exceed the GPU memory, the computation will fail.
USER_DEFINED
The input image is processed by tiles of a predefined size.
Enumeration
NONE
tileSize
The tile width and height in pixels. This parameter is used only in USER_DEFINED tiling mode.
Vector2u32
>=1
{1024, 1024}
cudaContext
CUDA context information.
CudaContext
nullptr
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, 6]
3
tiling_mode
The way to manage the GPU memory.
NONE
The entire input image is transferred to the GPU memory.
If the total input, intermediate and output data size exceed the GPU memory, the computation will fail.
USER_DEFINED
The input image is processed by tiles of a predefined size.
enumeration
NONE
tile_size
The tile width and height in pixels. This parameter is used only in USER_DEFINED tiling mode.
vector2u32
>=1
[1024, 1024]
cuda_context
CUDA context information.
cuda_context
None
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, 6]
3
tilingMode
The way to manage the GPU memory.
NONE
The entire input image is transferred to the GPU memory.
If the total input, intermediate and output data size exceed the GPU memory, the computation will fail.
USER_DEFINED
The input image is processed by tiles of a predefined size.
Enumeration
NONE
tileSize
The tile width and height in pixels. This parameter is used only in USER_DEFINED tiling mode.
Vector2u32
>=1
{1024, 1024}
cudaContext
CUDA context information.
CudaContext
null
outputImage
The output image. Its dimensions and type are forced to the same values as the input.