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
| N=input('quel est le nombre total d''images? ');
tail_disq=10; seuil=800; petite_aire=200;
for k=1:N
fname=sprintf('levures + 50mS par m + 3Vpp +44MHz_t00%d(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},'Orientation');
end
affiche=zeros(NbObjets{1},4); affiche(:,1)=1:NbObjets{1}; affiche(:,2)=1;
for k=1:N
regc=regionprops(L{k},'Centroid');
affiche(:,2*k+1:2*k+2)=cat(1, regc.Centroid);
end
x=affiche(:,3:2:end); y=affiche(:,4:2:end);
% déplacement des objets entre images
xs=diff(x,[],2); ys=diff(y,[],2);
for k=1:N-1
for i=1:NbObjets{1}
deplacement(i,k)=sqrt(xs(i,k)^2+ys(i,k)^2);
end
end
% distance entre objets balayage en x croissant
xs1=diff(x',[],2); ys1=diff(y',[],2); xs2=xs1'; ys2=ys1';
for k=1:N
for i=1:NbObjets{1}-1
distancex(i,k)=sqrt(xs2(i,k)^2+ys2(i,k)^2);
end
end
% distance entre objets balayage en y croissant
yx=[];
for i=3:2:2*N+2
xy=affiche(:,i:i+1);
yx=[yx sortrows(xy,2)];
end
x1=yx(:,1:2:end); y1=yx(:,2:2:end);
xs3=diff(x1',[],2); ys3=diff(y1',[],2); xs4=xs3'; ys4=ys3';
for k=1:N
for i=1:NbObjets{1}-1
distancey(i,k)=sqrt(xs4(i,k)^2+ys4(i,k)^2);
end
end
s=size(I{1}); diam=32; t1=1.5*diam; t2=2*diam; a=[]; |
Partager