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:
Label matrix of a segmented image

Subject: Label matrix of a segmented image

From: Mohi rad

Date: 7 Oct, 2010 10:31:06

Message: 1 of 9

I would like to inform you that I segmented an image using a software named 'EDISON'and I got
the segmented image as it's output.(you can get the software with the links below):

http://www.cs.ucf.edu/~vision/Code/Mean%20Shift/edison_src.zip
and
http://www.cs.ucf.edu/~vision/Code/Mean%20Shift/edison_binary.zip

As you know the marker-based segmentation methods like mean-shift or k-means give us label matrix of segmented image but other methods like
EDISON software give us only segmented image.

So, I have a question to you and I hope you answer to my question.
How can we get the label matrix of an image which is segmented by EDISON software?
Would you please give me a MATLAB code for this purpose?
thank you in advance for your attention.
Mohi-rad

Subject: Label matrix of a segmented image

From: Image Analyst

Date: 7 Oct, 2010 10:39:04

Message: 2 of 9

Why can't you just call bwlabel()?

Subject: Label matrix of a segmented image

From: Mohi rad

Date: 7 Oct, 2010 20:14:04

Message: 3 of 9

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <i8k808$rnh$1@fred.mathworks.com>...
> Why can't you just call bwlabel()?

As I know bwlabel acts on binary images but I have a colored segmented image.so, how can I use this command for a segmented image?

Subject: Label matrix of a segmented image

From: Sean

Date: 7 Oct, 2010 20:24:03

Message: 4 of 9

> As I know bwlabel acts on binary images but I have a colored segmented image.so, how can I use this command for a segmented image?

So make your colored image binary...
help rgb2gray
help gt %>
help lt %<

Subject: Label matrix of a segmented image

From: Mohi rad

Date: 8 Oct, 2010 12:12:03

Message: 5 of 9

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i8la93$5h1$1@fred.mathworks.com>...
> > As I know bwlabel acts on binary images but I have a colored segmented image.so, how can I use this command for a segmented image?
>
> So make your colored image binary...
> help rgb2gray
> help gt %>
> help lt %<

The fact of matter is that I want to calculate mean color of each parts of the segmented image. I write a matlab code for this purpose using label matrix.
Therfore, I should not convert the segmented image into binary format. For more explaination I write some part of my code here:

numLabels=max(L(:)); % L is the Label matrix
STATS=regionprops(L,'pixelIdxList');
im1=im(:,:,1);
im2=im(:,:,2);
im3=im(:,:,3);
MeanColors=zeros(numLabels,3);
for i=1:numLabels
    MeanColors(i,1)=mean(im1(STATS(i).PixelIdxList));
    MeanColors(i,2)=mean(im2(STATS(i).PixelIdxList));
    MeanColors(i,3)=mean(im3(STATS(i).PixelIdxList));
end

Subject: Label matrix of a segmented image

From: Image Analyst

Date: 8 Oct, 2010 12:55:05

Message: 6 of 9

Mohi rad:
First of all, you can get the number of objects directly as one of the outputs of bwlabel so you don't need to do:
numLabels=max(L(:)); % L is the Label matrix
Secondly, with R2008a and later, you can get the mean intensity directly from regionprops with the "MeanIntensity" measurement.

Subject: Label matrix of a segmented image

From: Sean

Date: 8 Oct, 2010 12:56:03

Message: 7 of 9


> The fact of matter is that I want to calculate mean color of each parts of the segmented image. I write a matlab code for this purpose using label matrix.
> Therfore, I should not convert the segmented image into binary format. For more explaination I write some part of my code here:
>
> numLabels=max(L(:)); % L is the Label matrix
> STATS=regionprops(L,'pixelIdxList');
> im1=im(:,:,1);
> im2=im(:,:,2);
> im3=im(:,:,3);
> MeanColors=zeros(numLabels,3);
> for i=1:numLabels
> MeanColors(i,1)=mean(im1(STATS(i).PixelIdxList));
> MeanColors(i,2)=mean(im2(STATS(i).PixelIdxList));
> MeanColors(i,3)=mean(im3(STATS(i).PixelIdxList));
> end

So what's wrong with the above? How is it creating results different from those which you expect?

I'll take a stab at it and say part of the issue is that you called regionprops before defining the sub images. Thus the returned PixelIdxList is linear indices into the 3-dimensional image. You're then using those indices on 2-dimensional images which is surely wrong. Try calling regionprops on each of the three sub images.

Subject: Label matrix of a segmented image

From: Image Analyst

Date: 8 Oct, 2010 13:22:03

Message: 8 of 9

It's not the way I'd do it, but I think it's basically right if you have one binary image that describes (locates) all colored regions no matter what their color is. So, for example, you have a binary image with two blobs - one where a purple region is (in the original RGB image), and another where an orange region is. Then the pixelidxList list gives you the coordinates for each blob in turn. Then he's extracting the mean R, mean G, and mean B value for each blob - the purple one and the orange one. But, like you, I'm not sure what the problem is, if any.

Subject: Label matrix of a segmented image

From: CKC

Date: 8 May, 2012 17:06:07

Message: 9 of 9

"Mohi rad" <mohi_rad2009@yahoo.com> wrote in message <i8k7ha$s4b$1@fred.mathworks.com>...
> I would like to inform you that I segmented an image using a software named 'EDISON'and I got
> the segmented image as it's output.(you can get the software with the links below):
>
> http://www.cs.ucf.edu/~vision/Code/Mean%20Shift/edison_src.zip
> and
> http://www.cs.ucf.edu/~vision/Code/Mean%20Shift/edison_binary.zip
>
> As you know the marker-based segmentation methods like mean-shift or k-means give us label matrix of segmented image but other methods like
> EDISON software give us only segmented image.
>
> So, I have a question to you and I hope you answer to my question.
> How can we get the label matrix of an image which is segmented by EDISON software?
> Would you please give me a MATLAB code for this purpose?
> thank you in advance for your attention.
> Mohi-rad

EDISON software give us segmented image and also the label map.
You need to return the label map & access it as second output argument
Before end of msseg function, store labels by L=double(labels);
& mention L in output argument list
[S L] = msseg(I,hs,hr,M)

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