I have binary image with non-uniform object. I want to extend this object with 2 pixels around the object's border. What is the best way to enlarge the object using Matlab?
+1
A:
Here you go. It's a slight modification of the code in the imdilate
documentation.
N = 2; % number of pixels to grow the borders
bw = imread('text.png');
se = ones(2*N + 1, 2*N + 1);
bw2 = imdilate(bw,se);
imshow(bw), title('Original')
figure, imshow(bw2), title('Dilated')
nialsh
2010-09-16 14:15:30