1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
clear all
close all
img_RGB = imread('groupe.bmp');
img_YCBCR = rgb2ycbcr(img_RGB);
img_grey = rgb2gray(img_YCBCR);
subplot(2,2,1)
imshow(img_YCBCR)
title('couleur')
subplot(2,2,2)
imshow(img_grey)
title('niveaux de gris')
[nl nc]=size(img_grey);
seuillage=zeros(nl,nc);
for i=1:nl
for j=1:nc
if(img_grey(i,j)<50)
seuillage(i,j)=25;
end
if(img_grey(i,j)>49)&(img_grey(i,j)<100)
seuillage(i,j)=75;
end
if(img_grey(i,j)>99)&(img_grey(i,j)<150)
seuillage(i,j)=125;
end
if(img_grey(i,j)>149)&(img_grey(i,j)<200)
seuillage(i,j)=175;
end
if(img_grey(i,j)>199)
seuillage(i,j)=225;
end
end
end
seuillage=uint8(seuillage); %Converti limage en 8 bits
subplot(2,2,3)
imshow(seuillage)
title('Image segmentée')
% SE=[0 1 0;1 1 1;0 1 0];
BW = edge(seuillage,'canny');
subplot(2,2,4)
imshow(BW)
title('Image filtrer par canny')
BW2 = imfill(BW,'holes');
figure, imshow(BW2)
P=PDIST(BW2,'mahalanobis'); |
Partager