Monday, August 2, 2010

Morphology Dilation

clear all; close all; clc;
a = imread('Bimage1.bmp');
a = imresize(a,[256,256]);
[m n]=size(a);
b = zeros([m n]);
figure,imshow(a);
w = [0 1 0 1 1 1 0 1 0]; % structuring element
for i=2:m-1
for j=2:n-1
con=0;
for k=i-1:i+1
for p=j-1:j+1
con=con+1;
s(con)= a(k,p)*w(con);
end
end

if sum(s) > 0
b(i,j)=1;
end
end
end
figure,imshow(b);

No comments: