Image Processing Toolbox User's Guide |
Syntax
IM2 = imdilate(IM,SE) IM2 = imdilate(IM,NHOOD) IM2 = imdilate(IM,SE,PACKOPT) IM2 = imdilate(...,PADOPT)
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 ({}
).
IM2 = imdilate(...,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' |
C ompute the full dilation. |
PADOPT
is analogous to the optional SHAPE
argument to the conv2
and filter2
functions.
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
This example dilates 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')
This example dilates 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 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.
imcrop | imdisplayrange |
© 1994-2005 The MathWorks, Inc.