skimage2.filters.rank.sum#

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

Return the local sum of pixels.

Note that the sum may overflow depending on the data type of the input array.

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.

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

Output image.

Examples

>>> from _skimage2.morphology import footprint_rectangle # Need to add 3D example
>>> import _skimage2.filters.rank as rank         # Cube seems to fail but
>>> img = np.array([[0, 0, 0, 0, 0],            # Ball can pass
...                 [0, 1, 1, 1, 0],
...                 [0, 1, 1, 1, 0],
...                 [0, 1, 1, 1, 0],
...                 [0, 0, 0, 0, 0]], dtype=np.uint8)
>>> rank.sum(img, footprint_rectangle((3, 3)))
array([[1, 2, 3, 2, 1],
       [2, 4, 6, 4, 2],
       [3, 6, 9, 6, 3],
       [2, 4, 6, 4, 2],
       [1, 2, 3, 2, 1]], dtype=uint8)