imdilate - Dilate image

Syntax

IM2 = imdilate(IM, SE)
IM2 = imdilate(IM, NHOOD)
IM2 = imdilate(IM, SE, PACKOPT)
IM2 = imdilate(...,SHAPE)

Description

IM2 = imdilate(IM, SE) dilates the grayscale, binary, or packed binary image IM, returning the dilated 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, imdilate performs binary dilation; otherwise, it performs grayscale dilation. If SE is an array of structuring element objects, imdilate performs multiple dilations of the input image, using each structuring element in SE in succession.

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

IM2 = imdilate(IM, SE, PACKOPT) or imdilate(IM,NHOOD,PACKOPT) specifies whether IM is a packed binary 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. If the value of PACKOPT is 'ispacked', PADOPT must be 'same'.

{'notpacked'}

IM is treated as a normal array.

IM2 = imdilate(...,SHAPE) specifies the size of the output image. SHAPE 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 dilation.

Class Support

IM can be logical or numeric and must be real and nonsparse. It can have any dimension. If IM is logical, SE must be flat. The output has the same class as the input. If the input is packed binary, then the output is also packed binary.

Examples

Dilate a binary image with a vertical line structuring element.

bw = imread('text.png');
se = strel('line',11,90);
bw2 = imdilate(bw,se);
imshow(bw), title('Original')
figure, imshow(bw2), title('Dilated')

Dilate a grayscale image with a rolling ball structuring element.

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

To determine the domain of the composition of two flat structuring elements, dilate the scalar value 1 with both structuring elements in sequence, using the 'full' option.

se1 = strel('line',3,0)
se1 =
 
Flat STREL object containing 3 neighbors.
Neighborhood:
     1     1     1

se2 = strel('line',3,90)
se2 =
 
Flat STREL object containing 3 neighbors.
Neighborhood:
     1
     1
     1

composition = imdilate(1,[se1 se2],'full')
composition =
     1     1     1
     1     1     1
     1     1     1

Algorithm

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

Dilation using bit packing is described in [2].

See Also

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

References

[1] Haralick, R.M., and L. 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.

  


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