I have a problem on this program, you can help me? thank you :
I = imread('cell.tif'); figure, imshow(I), title('original image'); text(size(I,2),size(I,1)+15, ... 'Image courtesy of Alan Partin', ... 'FontSize',7,'HorizontalAlignment','right'); text(size(I,2),size(I,1)+25, .... 'Johns Hopkins University', ... 'FontSize',7,'HorizontalAlignment','right'); [junk threshold] = edge(I, 'sobel'); fudgeFactor = .5; BWs = edge(I,'sobel', threshold * fudgeFactor); figure, imshow(BWs), title('binary gradient mask'); se90 = strel('line', 3, 90); se0 = strel('line', 3, 0); BWsdil = imdilate(BWs, [se90 se0]); figure, imshow(BWsdil), title('dilated gradient mask'); BWdfill = imfill(BWsdil, 'holes'); figure, imshow(BWdfill); title('binary image with filled holes'); BWnobord = imclearborder(BWdfill, 4); figure, imshow(BWnobord), title('cleared border image'); seD = strel('diamond',1); BWfinal = imerode(BWnobord,seD); BWfinal = imerode(BWfinal,seD); figure, imshow(BWfinal), title('segmented image'); Imdep = title('original image'); Imseg = title('segmented image'); 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)
Best Answer