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
| N=input('quel est le nombre total d''images? ');
tail_disq=10; petite_aire=200;
for k=1:N
fname=sprintf('levures + 50mS par m + 3Vpp +44MHz_t%03d(c1).jpg',k);
I{k}=imread(fname);
end
se=strel('disk',tail_disq);
for k=1:N
background{k}=imclose(I{k},se); I2{k}=imsubtract(background{k},I{k});
level=graythresh(I2{k}); bw{k}=im2bw(I2{k},level);
bw{k}=bwareaopen(bw{k},petite_aire); bw{k}=imclearborder(bw{k});
fill{k}=imfill(bw{k},'holes');
[etiquette{k},NbObjets{k}]=bwlabel(fill{k},8);
b{k}=bwboundaries(fill{k}); L{k}=bwlabel(fill{k});
rego{k}=regionprops(L{k},'All');
end
affiche=zeros(NbObjets{1},4);
affiche(:,1)=1:NbObjets{1};
affiche(:,2)=1; % création d'une matrice
for k=1:N
k
regc=regionprops(L{k},'Centroid');
affiche(:,2*k+1:2*k+2)=cat(1, regc.Centroid);
end |
Partager