How can i store the labeled coordinates in differnt arrays?

Asked by sameen on 20 Jul 2012
Latest activity Commented on by Image Analyst on 23 Jul 2012

i want to find the coordinates of labeled images .i got labeled values but issue is to separate the labels in separate array which just show me coordinates of label 1 and in the same way for the rest of my all labels till max for particular image

i got labels on 8-neighborhood basis and also show me max number of labels

L = bwlabel(B,8) mx=max(max(L))

i also showed all labels separately in figure form but rather than figure i need coordinates of those labeled object and for figures i used this (for loop)

for s=1:mx

[x y]=find(L==s);

figure, imshow(B(x,y));

end

actually i don't need to show figures i want coordinates of those figures which will store separately in some separate array of variables like label 1's coordinates will store in one array for label 2 in other array and so on till end please help me out ...I'll be thankful to you

0 Comments

sameen

Products

No products are associated with this question.

2 Answers

Answer by Image Analyst on 22 Jul 2012
Accepted answer

You can get the number of objects directly from the second return argument of bwlabel:

[labeledImage, numberOfRegions] = bwlabel(binaryImage);

You don't need to do it like you did this way:

mx=max(max(L))

With your second set of code, an attempt to show individual regions, you said that you don't want to do that (so why put it?), and that instead you want the x,y coordinates of the pixels in each region. You can get this from the PixelList measurement of regionprops:

measurements = regionprops(labeledImage, 'PixelList');

I rarely use this, so I'm wondering why you think you need to use it. What are you going to do next with those coordinates after you have them? These coordinates are not useful in themselves. They would only be useful as input to some next step of your algorithm. Perhaps I can tell you how to do the next step in a more efficient way, just like I could have told you to use ismember instead of "[x y]=find(L==s);" if you had wanted to look at individual regions.

2 Comments

sameen on 22 Jul 2012

actually i want these coordinates to further train in SVM library in csharp . and according to my supervisor's instruction i need those coordinates. can u further help me in doing that pls

Image Analyst on 23 Jul 2012

I don't know what he's after. If you have those coordinates, your image is already segmented, and possibly already classified, so I don't know what the SVM would do. What classes could the SVM split your blobs into with just the x,y coordinates? Blobs on the right, and blobs on the left?

Image Analyst
Answer by Matt Kindig on 20 Jul 2012

Run regionprops() on B, and then look at the 'PixelList' property.

4 Comments

Matt Kindig on 22 Jul 2012

I'm not sure how this is relevant to the question... did you perhaps mistakenly comment on the wrong question? What are u and v?

Image Analyst on 22 Jul 2012

Trust me - you don't need assignin().

Matt Kindig on 22 Jul 2012

True, you don't need assignin(). But did you try the regionprops() suggestion that I made?

Matt Kindig

Contact us