Hi
I am running a program to test the similarity between predicted images (after training ) and original ground truth images but my program is giving following error:
Index exceeds matrix dimensions.
Error in liang_for_other_3 (line 14)
nam=pics(ii).name;
I am also attaching my program here.
img='/home/SHussain/unet-master-zhixuhao/data/membrane/test/img/';cls='/home/SHussain/cls/';tp2=[];fn2=[];fp2=[];jac2=[];ac2=[];pics=dir(fullfile(img,'*_predict.bmp'));clss=dir(fullfile(cls,'*.bmp'));n1=numel(clss);ii=0;for i=1:n1ii=ii+1;nam=pics(ii).name;tr = fullfile(cls, clss(i).name);%tr=strcat(clss(ii).folder,'\',int2str(i-1),'.bmp');
tr2 = fullfile(img, pics(i).name);%tr2=strcat(pics(ii).folder,'\',int2str(i-1),'._predict.png');
if exist(tr2)==0||exist(tr)==0 continue;endimL=imread(tr);ims=imread(tr2);ims=im2uint8(ims);if(length(size(ims))==3)ims=rgb2gray(ims);end%ims=findtarget2(ims);
ims=imresize(ims,size(imL));%imwrite(ims,str2);
ims(ims<128)=0;ims(ims>=128)=255;imL(imL==1)=255;tp2(i)=TP(imL,ims);fn2(i)=FN(imL,ims);fp2(i)=FP(imL,ims);jac2(i)=Jaccard(imL,ims);cha=[];cha=double(imL)-double(ims);z1=[];z1=find(cha==0);ac2(i)=(size(z1,1)*size(z1,2))/(size(imL,1)*size(imL,2));endTPP=mean(tp2);FPP=mean(fp2);FNP=mean(fn2);JACD=mean(jac2);ACC=mean(ac2);% subplot(2,1,1);
% imshow(imL);
% subplot(2,1,2);
% imshow(ims);
Please guide me what is the peoblem with my code?
Best Answer