Multi-dimensional greyscale closing.
A greyscale closing consists in the succession of a greyscale dilation, and a greyscale erosion.
Parameters : | input : array_like
size : tuple of ints
footprint : array of ints, optional
structure : array of ints, optional
output : array, optional
mode : {‘reflect’,’constant’,’nearest’,’mirror’, ‘wrap’}, optional
cval : scalar, optional
origin : scalar, optional
|
---|---|
Returns : | output : ndarray
|
Notes
The action of a grayscale closing with a flat structuring element amounts to smoothen deep local minima, whereas binary closing fills small holes.
References
[R58] | http://en.wikipedia.org/wiki/Mathematical_morphology |
Examples
>>> a = np.arange(36).reshape((6,6))
>>> a[3,3] = 0
>>> a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17],
[18, 19, 20, 0, 22, 23],
[24, 25, 26, 27, 28, 29],
[30, 31, 32, 33, 34, 35]])
>>> ndimage.grey_closing(a, size=(3,3))
array([[ 7, 7, 8, 9, 10, 11],
[ 7, 7, 8, 9, 10, 11],
[13, 13, 14, 15, 16, 17],
[19, 19, 20, 20, 22, 23],
[25, 25, 26, 27, 28, 29],
[31, 31, 32, 33, 34, 35]])
>>> # Note that the local minimum a[3,3] has disappeared