function Res = Yasnoff2( FicImVT,FicImSeg ) %function Res = Yasnoff2( ImVT,ImSeg ) %besoin de res de seg ajustés 1 à n classes % % Utilitaires pour l'évaluation de la segmentation d'images % Toolbox matlab (version 5.3) % % (c) Laboratoire de Vision et Robotique (UPRES EA 2078) % ENSI de Bourges - Université d'Orléans % % Sébastien Chabrier : sebastien.chabrier@ensi-bourges.fr % % % Utilitaires pour l'évaluation de la segmentation d'images % Toolbox matlab (version 5.3) % % (c) Laboratoire de Vision et Robotique (UPRES EA 2078) % ENSI de Bourges - Université d'Orléans % % Sébastien Chabrier : sebastien.chabrier@ensi-bourges.fr % % Si vous utilisez cette toolbox, veuillez citer ce papier svp. % %S. Chabrier, B. Emile , H. Laurent, %"Psychovisual evaluation of an image segmentation result" , %8th International IEEE Conference on Signal Processing (ICSP), 2006. [ImVT PAL]=imread(FicImVT,'BMP'); [ImSeg PAL]=imread(FicImSeg,'BMP'); if (min(min(ImVT))==0) ImVT=double(ImVT)+1; else ImVT=double(ImVT); end; if (min(min(ImSeg))==0) ImSeg=double(ImSeg)+1; else ImSeg=double(ImSeg); end; [L,H]=size(ImVT); taille=L*H; n1=max(max(ImVT)); n2=max(max(ImSeg)); NBclassSEG=double(max(max(ImSeg))); NBclassVT=double(max(max(ImVT))); nbre2lig=size(ImVT,1); nbre2col=size(ImVT,2); % calcul des valeurs de recouvrement T=zeros(NBclassVT,NBclassSEG); for p=1:NBclassVT for o=1:NBclassSEG [M N]=find(ImVT(:,:)==p & ImSeg(:,:)==o); if (M) for i=1:length(M) p=ImVT(M(i),N(i)); o=ImSeg(M(i),N(i)); T(p,o)=T(p,o)+1; end; end; end; end; MatConf=zeros(max(NBclassSEG,NBclassVT));%MatConf(VT,SEG); MatConfVT =zeros(NBclassVT,1);%MatConf(VT,SEG); MatConfSeg=zeros(NBclassSEG,1);%MatConf(VT,SEG); [iT,jT]=size(T); maxi=zeros(NBclassSEG); for t=1:NBclassSEG maxi(t)=max(max(T)); for i=1:iT for j=1:jT, if (maxi(t)==T(i,j)) cormax=[i,j]; MatConf(i,j)=T(i,j); MatConfVT(i) =j; MatConfSeg(j)=i; end, end, end, T(cormax(1),:)=zeros(1,jT); T(:,cormax(2))=zeros(iT,1); end, %création matrice de correspondance Corr %Corr=zeros(n1,n2); %for i=1:n1 % for j=1:n2 % [A,B]=find(ImVT==i & ImSeg==j); % Corr(i,j)=length(A); % end; %end; Histo=zeros(NBclassVT,1); for i=1:L for j=1:H Histo(ImVT(i,j),1)=Histo(ImVT(i,j),1)+1; end; end; Res=0; for i=1:NBclassVT if (MatConfVT(i)>0) Res=Res+((Histo(i,1)-MatConf(i,MatConfVT(i)))/(taille-Histo(i,1))); else Res=Res+(Histo(i,1)/(taille-Histo(i,1))); end; end; Res=1-Res/NBclassVT; disp('Yasnoff2='); disp(Res);