dilation

dilation

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

Return greyscale morphological dilation of an image.

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

Parameters:

image : ndarray

Image array.

selem : ndarray, optional

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

out : ndarray, 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:

dilated : uint8 array, same shape and type as image

The result of the morphological dilation.

Notes

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

Examples

>>> # Dilation enlarges bright regions
>>> import numpy as np
>>> from skimage.morphology import square
>>> bright_pixel = np.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=np.uint8)
>>> dilation(bright_pixel, square(3))
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=uint8)
doc_scikit_image
2017-01-12 17:20:47
Comments
Leave a Comment

Please login to continue.