Image Processing Toolbox User's Guide Previous page   Next Page

Eroding an Image

To erode an image, use the imerode function. The imerode function accepts two primary arguments:

imerode also accepts three optional arguments: PADOPT, PACKOPT, and M.

The PADOPT argument affects the size of the output image. The PACKOPT argument identifies the input image as packed binary. If the image is packed binary, M identifies the number of rows in the original image. (Packing is a method of compressing binary images that can speed up the processing of the image. See the bwpack reference page for more information.)

The following example erodes the binary image circbw.tif:

  1. Read the image into the MATLAB workspace.
  2. Create a structuring element. The following code creates a diagonal structuring element object. (For more information about using the strel function, see Structuring Elements.)
  3. Call the imerode function, passing the image BW and the structuring element SE as arguments.
  1. Notice the diagonal streaks on the right side of the output image. These are due to the shape of the structuring element.

Previous page  Dilating an Image Combining Dilation and Erosion Next page

© 1994-2005 The MathWorks, Inc.