MATLAB: 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

assignment has more non-singleton rhs dimensions than non-singleton subscripts

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

Best Answer

img_res(i,j,:) = black;
And similar changes to the other assignments