skimage2.filters.median#
- skimage2.filters.median(image, footprint=None, out=None, mode='nearest', cval=0.0, behavior='ndimage')[source]#
Return local median of an image.
- Parameters:
- imagearray-like
Input image.
- footprintndarray, optional
If
behavior='rank',footprintis a 2-D array of 1âs and 0âs. Ifbehavior='ndimage',footprintis a N-D array of 1âs and 0âs with the same number of dimensions asimage. If None,footprintwill be a N-D array with 3 elements for each dimension (e.g., vector, square, cube, etc.).- outndarray, optional
If None, a new array is allocated. For
behavior='ndimage', dtype matches input. Forbehavior='rank', dtype followsskimage.filters.rank.median().- mode{âreflectâ, âconstantâ, ânearestâ, âmirrorâ, âwrapâ}, optional
The mode parameter determines how the array borders are handled, where
cvalis the value whenmodeis equal to âconstantâ. Default is ânearestâ.Added in version 0.15:
modeis used whenbehavior='ndimage'.- cvalscalar, optional
Value to fill past edges of input
imageifmodeis âconstantâ. Default is 0.0.Added in version 0.15:
cvalwas added in 0.15 and is used whenbehavior='ndimage'.- behavior{ândimageâ, ârankâ}, optional
Whether to use the old (i.e., scikit-image < 0.15) or the new behavior. The old behavior will call
skimage.filters.rank.median(). The new behavior will callscipy.ndimage.median_filter(). Default is ândimageâ.Added in version 0.15:
behavioris introduced in v0.15.Changed in version 0.16: Default
behaviorhas been changed from ârankâ to ândimageâ.
- Returns:
- outndarray
Output image. For
behavior='ndimage', dtype matches input. Forbehavior='rank', dtype followsskimage.filters.rank.median().
See also
skimage.filters.rank.medianRank-based implementation of the median filtering offering more flexibility with additional parameters but dedicated for unsigned integer images.
Examples
>>> import _skimage2 as ski2 >>> img = ski2.data.camera() >>> med = ski2.filters.median(img, ski2.morphology.disk(5))