www.gusucode.com > images 案例代码 matlab源码程序 > images/DilateAnImageUsingImdilateExample.m
%% Dilate an Image Using imdilate % This example shows how to dilate an image using the |imdilate| function. % The morphological dilation operation expands or thickens foreground % objects in an image. %% % Create a simple sample binary image containing one foreground object: the % square region of 1's in the middle of the image. BW = zeros(9,10); BW(4:6,4:7) = 1 %% % Create a structuring element to use with |imdilate|. You typically create % a structuring element that is the same shape as the object you are % dilating. SE = strel('square',3) %% % Dilate the image, passing the input image and the structuring element to % |imdilate|. Note how dilation adds a rank of 1's to all sides of the % foreground object. BW2 = imdilate(BW,SE)