medianfilter: Median filter

medfilt2d(image, kernel_size=3, engine='cpp')[source]

Apply a median filter on an image.

This median filter is using a ‘nearest’ padding for values past the array edges. If you want more padding options or functionalities for the median filter (conditional filter for example) please have a look at silx.math.medianfilter.

Parameters:
  • image (numpy.ndarray) – the 2D array for which we want to apply the median filter.
  • kernel_size (A int or a list of 2 int (kernel_height, kernel_width)) – the dimension of the kernel. Kernel size must be odd. If a scalar is given, then it is used as the size in both dimension. Default: (3, 3)
  • engine – the type of implementation to use. Valid values are: ‘cpp’ (default) and ‘opencl’
Returns:

the array with the median value for each pixel.

Note

if the opencl implementation is requested but is not present or fails, the cpp implementation is called.