skimage2.filters.rank.majority#

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

Assign to each pixel the most common value within its neighborhood.

Parameters:
imagendarray of dtype (int or float)

Image array.

footprint2-D array (integer or float)

The neighborhood expressed as a 2-D array of 1’s and 0’s.

outndarray of dtype int, optional

If None, a new array will be 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_yint, optional

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

Returns:
outndarray of dtype int, optional

Output image.

Examples

>>> import numpy as np
>>> import _skimage2 as ski2
>>> img = ski2.data.camera()
>>> rng = np.random.default_rng()
>>> volume = rng.integers(0, 255, size=(10, 10, 10), dtype=np.uint8)
>>> maj_img = ski2.filters.rank.majority(img, ski2.morphology.disk(5))
>>> maj_img_vol = ski2.filters.rank.majority(volume, ski2.morphology.ball(5))