black-tophat

black_tophat

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

Return black top hat of an image.

The black top hat of an image is defined as its morphological closing minus the original image. This operation returns the dark spots of the image that are smaller than the structuring element. Note that dark spots in the original image are bright spots after the black top hat.

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.

Returns:

opening : array, same shape and type as image

The result of the black top filter.

Examples

>>> # Change dark peak to bright peak and subtract background
>>> import numpy as np
>>> from skimage.morphology import square
>>> dark_on_grey = np.array([[7, 6, 6, 6, 7],
...                          [6, 5, 4, 5, 6],
...                          [6, 4, 0, 4, 6],
...                          [6, 5, 4, 5, 6],
...                          [7, 6, 6, 6, 7]], dtype=np.uint8)
>>> black_tophat(dark_on_grey, square(3))
array([[0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 1, 5, 1, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
doc_scikit_image
2017-01-12 17:20:18
Comments
Leave a Comment

Please login to continue.