Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix labels for color segmentation

Subject: matrix labels for color segmentation

From: francesco santi

Date: 21 Nov, 2008 23:11:03

Message: 1 of 3

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.

Subject: matrix labels for color segmentation

From: francesco santi

Date: 21 Nov, 2008 23:41:02

Message: 2 of 3

Please consider this code instead of the previous posted.


    temp=zeros(HLS_RESHAPE_ROWS,HLS_RESHAPE_COLS);
    for x = 1:HLS_RESHAPE_ROWS
        if (HLS_RESHAPE(x,4) == label)
            temp(x,1:3) = HLS_RESHAPE(x,1:3);
        end;
    end
MU=mean(temp);

Thanks very much in advance to whom could help me.

Subject: matrix labels for color segmentation

From: francesco santi

Date: 22 Nov, 2008 00:04:02

Message: 3 of 3

solved...

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us