|
I have a MxNx3 matrix which is a color image.
Then I add a 4th column to be used as labeling index for segmentation.
I reshape this matrix to a MNx4 matrix where the first 3 columns are the 3 color components and the 4th column are the labels index.
I need to compute mean and cov of the pixels with assigned label.
I thought about scanning the matrix looking for the rows having as 4th value in the row the same number of the label index.
temp=zeros(1,4);
for x = 1:3
if (RGB_columns(x,4) == label)
temp(x,:) = RGB_columns(x,:);
end;
end
MU = mean(temp(:,:));
In this way I should create the temp matrix with only the rows having the value that I am looking for in the label field...but I get this error message:
"Maximum recursion limit of 500 reached"
and if I change this value of course Matlab crashes.
|