Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (35 sloc) 950 Bytes
% ShowMorph Demo-script, showing the effects of morphological image manipulation
%
% ThH, Jan-2007
% Ver 1.0
% *******************************************************************
% Draw a black background ...
data = zeros(99,99);
% ... and a white square in the middle:
data(34:66,:) = 1;
data(:,1:33) = 0;
data(:,67:100) = 0;
% Then make a black point in the middle ...
data(49:51,49:51) = 0;
% ... and a white point at the edge of the image
data(85:87,85:87)=1;
% Show the image
imshow(data)
shg
% Now show the effects of dilation and erosion, in a separate figure,
% with a "Square" as a structural element.
figure
se = strel('square', 5);
subplot(2,2,1);
imshow(imerode(data, se));
title('Eroded');
subplot(2,2,2);
imshow(imdilate(data, se));
title('Dilated');
subplot(2,2,3);
imshow(imopen(data, se));
title('Opened (Dilation after Erosion)');
subplot(2,2,4);
imshow(imclose(data, se));
title('Closed (Erosion after Dilation)');
shg