Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: matrix labels for color segmentation
Date: Fri, 21 Nov 2008 23:11:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 17
Message-ID: <gg7f66$664$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227309063 6340 172.30.248.37 (21 Nov 2008 23:11:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 21 Nov 2008 23:11:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1612112
Xref: news.mathworks.com comp.soft-sys.matlab:502436


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.