Image Processing Toolbox User's Guide |
Dilating an Image
To dilate an image, use the imdilate
function. The imdilate
function accepts two primary arguments:
strel
function, or a binary matrix defining the neighborhood of a structuring element
imdilate
also accepts two optional arguments: PADOPT
and PACKOPT
. The PADOPT
argument affects the size of the output image. The PACKOPT
argument identifies the input image as packed binary. (Packing is a method of compressing binary images that can speed up the processing of the image. See the bwpack
reference page for information.)
This example dilates a simple binary image containing one rectangular object.
BW = zeros(9,10); BW(4:6,4:7) = 1 BW = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
To expand all sides of the foreground component, the example uses a 3-by-3 square structuring element object. (For more information about using the strel
function, see Structuring Elements.)
SE = strel('square',3) SE = Flat STREL object containing 3 neighbors. Neighborhood: 1 1 1 1 1 1 1 1 1
To dilate the image, pass the image BW
and the structuring element SE
to the imdilate
function. Note how dilation adds a rank of 1's to all sides of the foreground object.
Structuring Elements | Eroding an Image |
© 1994-2005 The MathWorks, Inc.