IDS peak ICV v1.5.0
Loading...
Searching...
No Matches
MedianFilter Class Reference

Public Member Functions

None __init__ (self)
 Initializes a MedianFilter instance with a default kernel size of 3 (3 × 3 neighborhood).
 
int kernel_size (self)
 The size of the kernel.
 
None kernel_size (self, int kernel_size)
 Sets the size of the kernel used for the median filter.
 
Image process (self, Union[Image, ids_peak_ipl.Image] image)
 Applies the median filter to the specified image.
 

Protected Attributes

int _kernel_size = 3
 

Detailed Description

Class for applying a median filter to an image.

The median filter is a non-linear, spatial filter used to reduce impulsive noise in images. It replaces each pixel with the median value of the pixels in its local neighborhood, defined by the specified kernel size. The kernel size corresponds to a square neighborhood (size x size grid) around each pixel, where the median is calculated.

This process preserves edges better than linear smoothing filters while effectively removing salt-and-pepper noise and small image artifacts. A larger kernel removes more noise but also reduces image detail.

Since
ids_peak_icv 1.1

Constructor & Destructor Documentation

◆ __init__()

None __init__ ( self)

Initializes a MedianFilter instance with a default kernel size of 3 (3 × 3 neighborhood).

Since
ids_peak_icv 1.1

Member Function Documentation

◆ kernel_size() [1/2]

int kernel_size ( self)

The size of the kernel.

Since
ids_peak_icv 1.1

◆ kernel_size() [2/2]

None kernel_size ( self,
int kernel_size )

Sets the size of the kernel used for the median filter.

The size of the kernel must be an odd number greater than 1 and smaller than the image dimensions. The kernel size defines the size of the neighborhood (in a size × size grid) used to calculate the median for each pixel.

A larger kernel removes more noise but also reduces image detail.

Parameters
kernel_sizeSize of the kernel used for the median filter.
Since
ids_peak_icv 1.1

◆ process()

Image process ( self,
Union[Image, ids_peak_ipl.Image] image )

Applies the median filter to the specified image.

Supported pixel formats
  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • RGB8
  • RGBa8
  • BGR8
  • BGRa8
  • Coord3D_C32f
  • Coord3D_ABC32f

See the Pixel and Pixel Format Specifications for a detailed description of the pixel formats.

Note
Processes the entire image, ignoring any specified image region.
Parameters
imageThe image to process.
Returns
The filtered image.
Exceptions
NotSupportedExceptionThe pixel format is unsupported.
NotPossibleExceptionThe kernel size must be an odd number greater than 1.
OutOfRangeExceptionThe kernel size exceeds the image dimensions.
Since
ids_peak_icv 1.1

Field Documentation

◆ _kernel_size

_kernel_size = 3
protected