{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / filters / rank / generic / majority

function

skimage.filters.rank.generic:majority

source: /dev/scikit-image/src/skimage/filters/rank/generic.py :1684

Signature

def   majority ( image footprint * out = None mask = None shift_x = 0 shift_y = 0 shift_z = 0 )

Summary

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

Parameters

image : ndarray of dtype (int or float)

Image array.

footprint : 2-D array (integer or float)

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

out : ndarray of dtype int, optional

If None, a new array will be allocated.

mask : ndarray 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 : int, optional

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

Returns

out : ndarray of dtype int, optional

Output image.

Examples

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

Aliases

  • skimage.filters.rank.majority