Image Processing Toolbox User's Guide Previous page   Next Page
imerode

Erode image

Syntax

Description

IM2 = imerode(IM,SE) erodes the grayscale, binary, or packed binary image IM, returning the eroded image IM2. The argument SE is a structuring element object or array of structuring element objects returned by the strel function.

If IM is logical and the structuring element is flat, imerode performs binary dilation; otherwise it performs grayscale erosion. If SE is an array of structuring element objects, imerode performs multiple erosions of the input image, using each structuring element in SE in succession.

IM2 = imerode(IM,NHOOD) erodes the image IM, where NHOOD is an array of 0's and 1's that specifies the structuring element neighborhood. This is equivalent to the syntax imerode(IM,strel(NHOOD)). The imerode function determines the center element of the neighborhood by floor((size(NHOOD)+1)/2)

IM2 = imerode(IM,SE,PACKOPT,M) or imerode(IM,NHOOD,PACKOPT,M) specifies whether IM is a packed binary image and, if it is, provides the row dimension M of the original unpacked image. PACKOPT can have either of the following values. Default value is enclosed in braces ({}).

Value
Description
'ispacked'
IM is treated as a packed binary image as produced by bwpack. IM must be a 2-D uint32 array and SE must be a flat 2-D structuring element.
{'notpacked'}
IM is treated as a normal array.

If PACKOPT is 'ispacked', you must specify a value for M.

IM2 = imerode(...,PADOPT) specifies the size of the output image. PADOPT can have either of the following values. Default value is enclosed in braces ({}).

Value
Description
{'same'}
Make the output image the same size as the input image. If the value of PACKOPT is 'ispacked', PADOPT must be 'same'.
'full'
Compute the full erosion.

PADOPT is analogous to the SHAPE input to the CONV2 and FILTER2 functions.

Class Support

IM can be numeric or logical and it can be of any dimension. If IM is logical and the structuring element is flat, the output image is logical; otherwise the output image has the same class as the input. If the input is packed binary, then the output is also packed binary.

Examples

This example erodes a binary image with a disk structuring element.

This example erodes a grayscale image with a rolling ball.

Algorithm Notes

imerode automatically takes advantage of the decomposition of a structuring element object (if a decomposition exists). Also, when performing binary dilation with a structuring element object that has a decomposition, imerode automatically uses binary image packing to speed up the dilation.

Erosion using bit packing is described in [2].

See Also

bwpack, bwunpack, conv2, filter2, imclose, imdilate, imopen, strel

References

[1]  Haralick, Robert M., and Linda G. Shapiro, Computer and Robot Vision, Vol. I, Addison-Wesley, 1992, pp. 158-205.

[2]  van den Boomgaard and van Balen, "Image Transforms Using Bitmapped Binary Images," Computer Vision, Graphics, and Image Processing: Graphical Models and Image Processing, Vol. 54, No. 3, May, 1992, pp. 254-258.


Previous page  imdivide imextendedmax Next page

© 1994-2005 The MathWorks, Inc.