Monday, August 2, 2010

Morphology Edge Detection

clear all; close all; clc;
a = imread('circles.png');
a = imresize(a,[256,256]);
%a = imcrop(a);
[m n]=size(a);
b = zeros([m n]);
figure,imshow(a);
w = [1 1 1 1 1]; % structuring element
for i=1:m-1
for j=3:n-2
con=0;
for p=j-2:j+2
con=con+1;
s(con)= a(i,p)*w(con);
end
s1 = 1;
for r=1:con
s1 = s1*s(r);
end
if s1 > 0
b(i,j)=1;
end
end
end
figure,imshow(b);
f1 = a-b;
figure,imshow(f1);

No comments: