Let be a grayscale image, mapping points from a Euclidean space or discrete grid E (such as R2 or Z2) into the real line. Let be a grayscale structuring element. Usually, b is symmetric and has short-support, e.g.,
.
Then, the morphological gradient of f is given by:
,
where and denote the dilation and the erosion, respectively.
An internal gradient is given by:
,
and an external gradient is given by:
.
The internal and external gradients are "thinner" than the gradient, but the gradient peaks are located on the edges, whereas the internal and external ones are located at each side of the edges. Notice that .
If , then all the three gradients have non-negative values at all pixels.
References
Image Analysis and Mathematical Morphology by Jean Serra, ISBN0-12-637240-3 (1982)
Image Analysis and Mathematical Morphology, Volume 2: Theoretical Advances by Jean Serra, ISBN0-12-637241-1 (1988)
An Introduction to Morphological Image Processing by Edward R. Dougherty, ISBN0-8194-0845-X (1992)