erosion

erosion

skimage.morphology.erosion(image, selem=None, *args, **kwargs) [source]

Return greyscale morphological erosion of an image.

Morphological erosion sets a pixel at (i,j) to the minimum over all pixels in the neighborhood centered at (i,j). Erosion shrinks bright regions and enlarges dark regions.

Parameters:

image : ndarray

Image array.

selem : ndarray, optional

The neighborhood expressed as an array of 1’s and 0’s. If None, use cross-shaped structuring element (connectivity=1).

out : ndarrays, optional

The array to store the result of the morphology. If None is passed, a new array will be allocated.

shift_x, shift_y : bool, optional

shift structuring element about center point. This only affects eccentric structuring elements (i.e. selem with even numbered sides).

Returns:

eroded : array, same shape as image

The result of the morphological erosion.

Notes

For uint8 (and uint16 up to a certain bit-depth) data, the lower algorithm complexity makes the skimage.filter.rank.minimum function more efficient for larger images and structuring elements.

Examples

>>> # Erosion shrinks bright regions
>>> import numpy as np
>>> from skimage.morphology import square
>>> bright_square = 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)
>>> erosion(bright_square, square(3))
array([[0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
doc_scikit_image
2017-01-12 17:20:54
Comments
Leave a Comment

Please login to continue.