Products & Services Solutions Academia Support User Community Company

Learn more about Image Processing Toolbox   

imerode - Erode image

Syntax

IM2 = imerode(IM,SE)
IM2 = imerode(IM,NHOOD)
IM2 = imerode(...,PACKOPT,M)
IM2 = imerode(...,SHAPE)

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 erosion; 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(...,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(...,SHAPE) specifies the size of the output image. SHAPAE can have either of the following values. Default value is enclosed in braces ({}).

ValueDescription

{'same'}

Make the output image the same size as the input image. If the value of PACKOPT is 'ispacked', SHAPE must be 'same'.

'full'

Compute the full erosion.

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

Erode a binary image with a disk structuring element.

originalBW = imread('circles.png');  
se = strel('disk',11);        
erodedBW = imerode(originalBW,se);
imshow(originalBW), figure, imshow(erodedBW)

Erode a grayscale image with a rolling ball.

I = imread('cameraman.tif');
se = strel('ball',5,5);
I2 = imerode(I,se);
imshow(I), title('Original')
figure, imshow(I2), title('Eroded')

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 Boomgard, R, and R. van Balen, "Methods for Fast Morphological Image Transforms Using Bitmapped Images," Computer Vision, Graphics, and Image Processing: Graphical Models and Image Processing, Vol. 54, Number 3, pp. 254-258, May 1992.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS