原文:http://blogs.mathworks.com/steve/2006/09/25/dilation-erosion-and-the-morphological-gradient/
The morphological operator dilation acts like a local maximum operator. Erosion acts like a local minimum operator. You can use them together to compute something called the morphological gradient.
Dilation
The basic form of grayscale image dilation computes, for each image pixel, the maximum value of its neighboring pixels. The neighborhood is defined by the structuring element. For example, this structuring element:
se1 = strel([1 1 1])
defines a neighborhood consisting of the pixel itself, together with its left and right neighbors.
Erosion
Grayscale image erosion computes the minimum of each pixel's neighborhood.
Morphological gradient
Dilation and erosion are often used in combination to produce a desired image processing effect. One simple combination is the morphological gradient. P. Soille, in section 3.8 of the second edition of Morphological Image Analysis: Principles and Applications, talks about three kinds of basic morphological gradients:
- dilated_image - eroded_image
- original_image - eroded_image
- dilated_image - original_image
Soille calls the first one the basic morphological gradient, and you compute it this way using MATLAB and the Image Processing Toolbox:
The second form is called the half-gradient by erosion or internal gradient.
"The internal gradient enhances internal boundaries of objects brighter than their background and external boundaries of objects darker than their background. For binary images, the internal gradient generates a mask of the internal boundaries of the foreground image objects." [Soille, page 86]
The third form is called the half-gradient by dilation or external gradient:
Direction gradients
By using line segments as structuring elements, you can compute directional gradients.