skimage2.filters.rank.median#

skimage2.filters.rank.median(image, footprint=None, out=None, mask=None, shift_x=0, shift_y=0, shift_z=0)[source]#

Return local median of an image.

Parameters:
imagendarray of shape ([P,] M, N) and dtype (uint8 or uint16)

Input image.

footprintndarray

The neighborhood expressed as an ndarray of 1’s and 0’s. If None, a full square of size 3 is used.

outndarray of shape ([P,] M, N), same dtype as input image

If None, a new array is allocated.

maskndarray of dtype (int or float), optional

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y, shift_zint

Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).

Returns:
out([P,] M, N) ndarray, same dtype as image

Output image.

See also

skimage.filters.median

Implementation of a median filtering which handles images with floating precision.

Examples

>>> from _skimage2 import data
>>> from _skimage2.morphology import disk, ball
>>> from _skimage2.filters.rank import median
>>> import numpy as np
>>> img = data.camera()
>>> rng = np.random.default_rng()
>>> volume = rng.integers(0, 255, size=(10,10,10), dtype=np.uint8)
>>> med = median(img, disk(5))
>>> med_vol = median(volume, ball(5))