Multi-dimensional greyscale opening.
A greyscale opening consists in the succession of a greyscale erosion, and a greyscale dilation.
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 opening with a flat structuring element amounts to smoothen high local maxima, whereas binary opening erases small objects.
References
[R52] | http://en.wikipedia.org/wiki/Mathematical_morphology |
Examples
>>> a = np.arange(36).reshape((6,6))
>>> a[3, 3] = 50
>>> a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17],
[18, 19, 20, 50, 22, 23],
[24, 25, 26, 27, 28, 29],
[30, 31, 32, 33, 34, 35]])
>>> ndimage.grey_opening(a, size=(3,3))
array([[ 0, 1, 2, 3, 4, 4],
[ 6, 7, 8, 9, 10, 10],
[12, 13, 14, 15, 16, 16],
[18, 19, 20, 22, 22, 22],
[24, 25, 26, 27, 28, 28],
[24, 25, 26, 27, 28, 28]])
>>> # Note that the local maximum a[3,3] has disappeared