I am trying to find out performace metrics of an binary image, but I'm getting this error message : Assignment has more non-singleton rhs dimensions than non-singleton subscripts inline no.36
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Bibhu Prasad  Das
 el 22 de Mzo. de 2017
  
    
    
    
    
    Comentada: Bibhu Prasad  Das
 el 22 de Mzo. de 2017
            Recall = 0; %# TP / (TP + FN)
Precision = 0; %# TP / (TP + FP)
Fscore = 0; %# 2*(Precision*Recall)/(Precision+Recall)
green = [0,255,0];%# for FN
blue  = [255,0,0]; 
red   = [0,0,255]; %# for FP
white = [255,255,255];% # for TP
black = [0,0,0]; %# for TN
TP = 0; %# True positive pixels
FP = 0;  %# False positive pixels
TN = 0; %# True negative pixels
FN = 0; %# False negative pixels
y_res = 240; % Y - Resolution of the Image
x_res = 320; % X - Resolution of the Image
img_res=im2uint8(zeros(x_res,y_res,3));
img_gt=imread('gnd0005.bmp');
fg=imread('im0005.png');
img_fg=(imresize(fg,[320 240 ]));
for i = 1: y_res
  for j = 1: x_res
    pixel_gt = img_gt(i,j);% # ground-truth
    pixel_fg = img_fg(i,j); %# binary image
    if(pixel_gt == 255 && pixel_fg == 255);
        TP = TP + 1;
        img_res(i,j) = white;
            elseif(pixel_gt == 0 && pixel_fg == 255);
        FP = FP + 1;
        img_res(i,j) = red;
            elseif(pixel_gt == 0 && pixel_fg == 0);
        TN = TN + 1;
        img_res(i,j) = black;
            elseif(pixel_gt == 255 && pixel_fg == 0);
        FN = FN + 1;
        img_res(i,j) = green;
    end
  end
end
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 22 de Mzo. de 2017
         img_res(i,j,:) = black;
And similar changes to the other assignments
Más respuestas (1)
  Image Analyst
      
      
 el 22 de Mzo. de 2017
        Two other problems with your code.
First is that there are no comments.
Second is that you reversed x and y. In the for loop you have it correct -- img_res(i, j) which is img_res(y, x). However when you preallocated it you used
img_res=im2uint8(zeros(x_res,y_res,3)); % x and y in reverse order.
instead of
img_res = zeros(y_res,x_res,3, 'uint8'); % x and y in proper order.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


