In the example bellow, the input image (figure 2) is dilated by the structuring element seen on figure 1, resulting the image shown on figure 3. The same input image is eroded by the same structuring element than before and the result is seen in the image shown on figure 4. The image on figure 5, the final result, is the morphological subtraction of the dilation and the erosion.
One important application of the morphologic gradient in binary images is to find their bounderies.
0 1 0 1 1 1 fig 1. Structuring element used 0 1 0
fig. 2 - Input image
fig. 3 - The Dilation
fig. 4 - The Erosion
fig. 5 - The Subtraction
The same operator applied to graylevel images, but without filtering it does not produce good results because it is very sensible to noise. Figure 6 show a gray scale image and figure 7 its gradient (negated in order to show the details of the image), using the 3x3 square as structural element.
fig. 6 - Input image
fig. 7 - Negation of the gradient.