{ } Raw JSON

bundles / skimage latest / skimage / filters / rank / generic / pop

function

skimage.filters.rank.generic:pop

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

Signature

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

Summary

Return the local number (population) of pixels.

Extended Summary

The number of pixels is defined as the number of pixels which are included in the footprint and the mask.

Parameters

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

Input image.

footprint : ndarray

The neighborhood expressed as an ndarray of 1's and 0's.

out : ndarray of shape ([P,] M, N), same dtype as input `image`

If None, a new array is 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, shift_z : int

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 shape ([P,] M, N), same dtype as input `image`

Output image.

Examples

from skimage.morphology import footprint_rectangle # Need to add 3D example
import skimage.filters.rank as rank
img = 255 * np.array([[0, 0, 0, 0, 0],
                      [0, 1, 1, 1, 0],
                      [0, 1, 1, 1, 0],
                      [0, 1, 1, 1, 0],
                      [0, 0, 0, 0, 0]], dtype=np.uint8)
rank.pop(img, footprint_rectangle((3, 3)))

Aliases

  • skimage.filters.rank.pop