Visualize output of Morphological reconstruction in each iteration | MATLAB

preview_player
Показать описание
Code is given in the comment section.

Learn Image Processing using MATLAB:

#DigitalImageProcessing #MATLAB #ComputerVision
Рекомендации по теме
Комментарии
Автор

Code:
clc
clear all
close all
warning off

x=imfill(x, 'holes');
k=input('How many points you want to enter?');
imshow(x);
[a b]=size(x);
h_k=zeros(a, b);
temp=0;
while temp<k
gk=zeros(a, b);
[m n]=ginput(1);
m=round(m);
n=round(n);
gk(n, m)=1;
h_k=h_k+gk;
temp=temp+1;
end
imshow(h_k);
se=ones(3);
previous=h_k;
current=(imdilate(previous, se) & x);
output=zeros(a, b, 3);
figure;
pause(3);
while ~isequal(previous, current)
previous=current;
current=(imdilate(previous, se) & x);
output(:, :, 2)=current;
subplot(1, 2, 1);
imshow(x);
subplot(1, 2, 2);
imshow(output);
drawnow limitrate;
end


Note:It is not always required to use imfill, it is just taken for this particular image, depending on the image you are taking, you have to use imfill or imcomplement . Happy Coding :-)

KnowledgeAmplifier
join shbcf.ru