Image Processing Toolbox    

Related Operations

There are many other types of morphological operations in addition to dilation and erosion. However, many of these operations are just modified dilations or erosions, or combinations of dilation and erosion. For example, closure consists of a dilation operation followed by erosion with the same structuring element. A related operation, opening, is the reverse of closure; it consists of erosion followed by dilation.

For example, suppose you want to remove all the circuit lines from the original circuit image, leaving only the rectangular outlines of microchips. You can accomplish this through opening.

To perform the opening, you begin by choosing a structuring element. This structuring element should be large enough to remove the lines when you erode the image, but not large enough to remove the rectangles. It should consist of all 1's, so it removes everything but large continuous patches of foreground pixels. Therefore, you create the structuring element like this.

Next, you perform the erosion. This removes all of the lines, but also shrinks the rectangles.

Finally, you perform dilation, using the same structuring element, to restore the rectangles to their original sizes.

Predefined Operations

You can use dilate and erode to implement any morphological operation that can be defined as a set of dilations and erosions. However, there are certain operations that are so common that the toolbox provides them as predefined procedures. These operations are available through the bwmorph function. bwmorph provides eighteen predefined operations, including opening and closure.

For example, suppose you want to reduce all objects in the circuit image to lines, without changing the essential structure (topology) of the image. This process is known as skeletonization. You can use bwmorph to do this.

Figure 9-3: Circbw.tif Before and After Skeletonization

The third argument to bwmorph indicates the number of times to perform the operation. For example, if this value is 2, the operation is performed twice, with the result of the first operation being used as the input for the second operation. In the example above, the value is Inf. In this case bwmorph performs the operation repeatedly until it no longer changes.

For more information about the predefined operations available, see the reference page for bwmorph.


 Dilation and Erosion Object-Based Operations