function Res = Yasnoff1( FicImVT,FicImSeg ) %function Res = Yasnoff1 ( 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, HistoVT=zeros(NBclassVT,1); for i=1:L for j=1:H HistoVT(ImVT(i,j),1)=HistoVT(ImVT(i,j),1)+1; end; end; HistoSEG=zeros(NBclassSEG,1); for i=1:L for j=1:H HistoSEG(ImSeg(i,j),1)=HistoSEG(ImSeg(i,j),1)+1; end; end; %% après le calcul des tailles des classes et des correspondances, calcul du critère à proprement parler Res1=0; %R1=VT, R2=Seg for i=1:L for j=1:H if (MatConfVT(ImVT(i,j))>0) Res1=Res1+(HistoVT(ImVT(i,j))-MatConf(ImVT(i,j),MatConfVT(ImVT(i,j))))/HistoVT(ImVT(i,j)); else Res1=Res1+1; end; end; end; Res2=0; %R1=Seg, R2=VT for i=1:L for j=1:H if (MatConfSeg(ImSeg(i,j))>0) Res2=Res2+(HistoSEG(ImSeg(i,j))-MatConf(MatConfSeg(ImSeg(i,j)),ImSeg(i,j)))/HistoSEG(ImSeg(i,j)); else Res2=Res2+1; end; end; end; Res=1-min(Res1,Res2)/taille; disp('Martin1='); disp(Res);