I= imread('main.png');
sigma=2;
N=3;
M=3;
w=fspecial('gaussian', [N M], sigma);
F=imfilter(I, w);
HSV=rgb2hsv(I);
H = HSV(:,:,1);
imshow(H)
B = H > 0.5;
figure;
imshow(B)
A=B;
C=strel('disk', 2,0);
Silhouette=imclose(A,C);
figure,
imshow(Silhouette);
E=Silhouette;
elem3x3=ones(3);
D=imdilate(E,elem3x3);
Contour= D-E;
figure;
imshow(Contour);
hitN =[000;010;111];
missN =[111;000;000];
hitS =[111;010;000];
missS =[000;000;111];
hitE =[100;110;100];
missE =[001;001;001];
hitO =[001;011;001];
missO =[100;100;100];
hitNE =[000;110;010];
missNE =[011;001;000];
hitSE =[010;110;000];
missSE =[000;001;011];
hitNO =[000;011;010];
missNO =[110;100;000];
hitSO =[010;011;000];
missSO =[000;100;110];
Squel = Silhouette;
SquelPrecedent = 0;
while(~isequal(Squel, SquelPrecedent))
SquelPrecedent = Squel;
hmN = imerode(Squel, hitN) & imerode(~Squel, missN);
hmS = imerode(Squel, hitS) & imerode(~Squel, missS);
***hmE = imerode(Squel, hitE) & imerode(~Squel, missE);
hmO = imerode(Squel, hitO) & imerode(~Squel, missO);
hm = hmN | hmS | hmE | hmO;
Squel = Squel-hm;
hmNE = imerode(Squel, hitNE) & imerode(~Squel, missNE);
hmSE = imerode(Squel, hitSE) & imerode(~Squel, missSE);
hmNO = imerode(Squel, hitNO) & imerode(~Squel, missNO);
hmSO = imerode(Squel, hitSO) & imerode(~Squel, missSO);
hm = hmNE | hmSE | hmNO | hmSO ;
Squel = Squel-hm;
imshow(Squel); drawnow;
end
figure;
subplot(1,2,1); imshow(Silhouette);
subplot(1,2,2); imshow(Squel);
My code throws an error where I put *
hmE = imerode(Squel, hitE) & imerode(~Squel, missE);

Réponses (1)

Image Analyst
Image Analyst le 10 Avr 2022

0 votes

You need commas between the numbers. So not
hitN =[000;010;111];
but
hitN = [0,0,0; 0,1,0; 1,1,1];

Catégories

En savoir plus sur Images dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by