evaluation of segmentation image

I have this program that the evaluation of image segmentation, but I just can not run this program.
function [val] = IntraInter_LN(Imseg,Imori)
% function [val] = IntraInter_LN(Imseg,Imori)
% Calcul du critère d'évaluation Intra-Inter de Lévine & Nazif
% Imseg : matrice correspondant à l'image segmentée avec des valeurs allant de 1 à n pour les n régions segmentées
% Imori : matrice correspondant à l'image originale
%
% 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, C. Rosenberger, H. Laurent,
%"Unsupervised performance evaluation of image segmentation",
%Special Issue on Performance Evaluation in Image Processing,
%EURASIP Journal on Applied Signal Processing, pages 1-12, 2006.
if (min(min(Imseg))==0)
Imseg=double(Imseg)+1;
end;
NBclass=double(max(max(Imseg)));
nbre2lig=size(Imori,1);
nbre2col=size(Imori,2);
% statistiques sur les l'image originale
moy=zeros(NBclass,1);
cpt=zeros(NBclass,1);
var=zeros(NBclass,1);
for i=1:nbre2lig
for j=1:nbre2col
moy(Imseg(i,j))=double(moy(Imseg(i,j)))+double(Imori(i,j));
var(Imseg(i,j))=double(var(Imseg(i,j)))+double(Imori(i,j))*double(Imori(i,j));
cpt(Imseg(i,j))=double(cpt(Imseg(i,j)))+1;
end;
end;
for i=1:NBclass
if (cpt(i)~=0)
moy(i)=moy(i)/cpt(i);
var(i)=var(i)/cpt(i);
end;
var(i)=var(i)-moy(i)*moy(i);
end;
% disparite intraclasse
aux1=0.0;
for i=1:NBclass
aux1=aux1+(4.0/(255.0*255.0))*var(i);
end;
aux1=aux1/NBclass;
% disparite interclasse
aux2=0.0;
cpt2=0;
for i=1:NBclass
aux=0.0;
for j=1:NBclass
if (i~=j)
aux=aux+abs(moy(i)-moy(j))/512;
cpt2=cpt2+1;
end;
end;
aux2=aux2+aux;
end;
if (cpt2>0)
aux2=aux2/cpt2;
end;
val=(1+aux2-aux1)/2;
disp(val)

 Respuesta aceptada

Walter Roberson
Walter Roberson el 17 de Ag. de 2011

0 votos

What happens when you try to run it?
What data class should the input images be? Should they be grayscale (2 dimensional) or RGB (3 dimensional) ?

6 comentarios

hamaimi sarah
hamaimi sarah el 18 de Ag. de 2011
data must be images in grayscale (two dimensions),
bmp image to an 8-bit grayscale stored as a matrix
Walter Roberson
Walter Roberson el 18 de Ag. de 2011
Ah, I was correct in my mental prediction of grayscale uint8 images.
Okay, so now the other question that you skipped over: what happens when you try to run the code, and how does that differ from your expected results?
hamaimi sarah
hamaimi sarah el 22 de Ag. de 2011
I tried with this program and this is what I have as a result:
Function definitions are not permitted in this context.
Index Exceeds matrix dimensions.
Imdep= imread('imdep.bmp');
i=im2double(Imdep);
figure(1),imshow(i);
u=i(:,:,2);
Imseg= imread('imseg.bmp');
i2=im2double(Imseg);
figure(2),imshow(i2);
u=i2(:,:,2);
function valeur= Inter_LN(Imdep,Imseg)
% Calcul du contraste inter-région de Lévine et Nazif
% pour une image bmp 8bits en niveaux de gris stockée sous la forme d'une matrice
% Imseg : matrice correspondant à l'image segmentée avec des valeurs allant de 1 à n pour les n régions segmentées
% Imdep : matrice correspondant à l'image originale
%
%
% 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, C. Rosenberger, H. Laurent,
%"Unsupervised performance evaluation of image segmentation",
%Special Issue on Performance Evaluation in Image Processing,
%EURASIP Journal on Applied Signal Processing, pages 1-12, 2006.
valeur=0;
NBCLASS=double(max(max(Imseg)));
moyenne=zeros(1,NBCLASS);
contraste=zeros(1,NBCLASS);
contraste_croise=zeros(NBCLASS);
perimetre=zeros(1,NBCLASS);
frontiere=zeros(NBCLASS);
aire=zeros(1,NBCLASS);
for k=1:NBCLASS
[region_k]=find(Imseg==k);
aire(k)=length(region_k); %nb de pixels de la région k
if (aire(k)>0)
moyenne(k)=sum(sum(Imdep(region_k)))/aire(k);
else
moyenne(k)=0;
end;
Imbin=zeros(size(Imseg));
Imbin(region_k)=ones(size(region_k));
contour_k=find((double(dilate(Imbin,ones(3)))-double(Imbin))==1);
for l=1:NBCLASS
if (contour_k)
M=find(Imseg(contour_k)==l);
if (M)
frontiere(k,l)=length(M);
else
frontiere(k,l)=0;
end;
else
frontiere(k,l)=0;
end;
end;
perimetre(k)=length(contour_k);
if (perimetre(k)==0)
frontiere(k,:)=0;
else
frontiere(k,:)=frontiere(k,:)/perimetre(k);
end;
end;
for k=1:NBCLASS
for l=1:NBCLASS
if (moyenne(k)+moyenne(l)==0)
contraste_croise(k,l)=0;
else
contraste_croise(k,l)=abs(moyenne(k)-moyenne(l))/(moyenne(k)+moyenne(l));
end;
end;
contraste(k)=frontiere(k,:)*contraste_croise(k,:)';
end;
%[contraste_croise]
%pause;
valeur=(aire*contraste')/sum(aire);
disp(valeur)
Walter Roberson
Walter Roberson el 22 de Ag. de 2011
Remove the lines that you added before the "function" statement, and put those lines in a different file. Then, in that new file, add a line at the bottom,
valeur = Inter_LN(Imdep,Imseg);
hamaimi sarah
hamaimi sarah el 29 de Ag. de 2011
I still have the same problem
how I did
Walter Roberson
Walter Roberson el 29 de Ag. de 2011
Please show the different files and their contents, including indicating the file name for each of them.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Modify Image Colors en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by