How can i store the labeled coordinates in differnt arrays?

1 visualización (últimos 30 días)
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

Respuesta aceptada

Image Analyst
Image Analyst el 22 de Jul. de 2012
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 comentarios
sameen
sameen el 22 de Jul. de 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
Image Analyst el 23 de Jul. de 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?

Iniciar sesión para comentar.

Más respuestas (1)

Matt Kindig
Matt Kindig el 20 de Jul. de 2012
Run regionprops() on B, and then look at the 'PixelList' property.
  4 comentarios
Image Analyst
Image Analyst el 22 de Jul. de 2012
Trust me - you don't need assignin().
Matt Kindig
Matt Kindig el 22 de Jul. de 2012
True, you don't need assignin(). But did you try the regionprops() suggestion that I made?

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by