Image Processing Toolbox User's Guide Previous page   Next Page

Combining Dilation and Erosion

Dilation and erosion are often used in combination to implement image processing operations. For example, the definition of a morphological opening of an image is an erosion followed by a dilation, using the same structuring element for both operations. The related operation, morphological closing of an image, is the reverse: it consists of dilation followed by an erosion with the same structuring element.

The following section uses imdilate and imerode to illustrate how to implement a morphological opening. Note, however, that the toolbox already includes the imopen function, which performs this processing. The toolbox includes functions that perform many common morphological operations. See Dilation- and Erosion-Based Functions for a complete list.

Morphological Opening

You can use morphological opening to remove small objects from an image while preserving the shape and size of larger objects in the image. For example, you can use the imopen function to remove all the circuit lines from the original circuit image, circbw.tif, creating an output image that contains only the rectangular shapes of the microchips.

To morphologically open the image, perform these steps:

  1. Read the image into the MATLAB workspace.
  2. Create a structuring element.
  1. The 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 contiguous patches of foreground pixels.

  1. Erode the image with the structuring element.
  1. This removes all the lines, but also shrinks the rectangles.

  1. To restore the rectangles to their original sizes, dilate the eroded image using the same structuring element, SE.

Previous page  Eroding an Image Dilation- and Erosion-Based Functions Next page

© 1994-2005 The MathWorks, Inc.