Finding pixels in connected component

Hi
I need to know how to get access to any white pixel in a connected component. Are there any functions to get the coordinates of white pixels? With that I have to start a traversal algorithm to draw a bounding box around the connected component in the image. Please help me out. Thank you very much!

 Akzeptierte Antwort

Image Analyst
Image Analyst am 27 Sep. 2012
Bearbeitet: Image Analyst am 27 Sep. 2012

0 Stimmen

Call regionprops(). You can ask for PixelIdxList which will give you the index (location) of every pixel in the blob. But if you just want the bounding box, no need to do some traversal algorithm, just ask regionprops() for the 'BoundingBox'. See my image segmentation tutorial for a demo: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

3 Kommentare

Muffin
Muffin am 27 Sep. 2012
Hi, thanks for ur reply! I found the PixelIdxList function but i'm lost as how to retrieve the index coordinate of the pixel, as in the code...
As for the bounding box by regionprops, would it bound using a rectangle just around the component with the white pixels?
Image Analyst
Image Analyst am 27 Sep. 2012
OK, so we now know that you don't need PixelIdxList so let's forget about that. I can tell you didn't look at my BlobsDemo program or you'd know that that's just what BoundingBox does. For each blobs, it gives that blob's bounding box, as shown in my demo.
Muffin
Muffin am 10 Okt. 2012
Hey, thanks a lot, your tutorial was of help! I managed to draw my bounding boxes!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Ryan
Ryan am 27 Sep. 2012
Bearbeitet: Ryan am 27 Sep. 2012

0 Stimmen

It sounds like you are looking for a perimeter of a shape as the "bounding box." If so, use bwboundaries to index the perimeter points. It pics the top most and then left most pixel as a starting point for the perimeter I believe.
[P C] = bwboundaries(A,'noholes'); % Records perimeter points
Perimeter = cat(2,P{1,1}); % Convert it to a vector

3 Kommentare

Muffin
Muffin am 28 Sep. 2012
hey is this perimeter precisely around the component or in a form of a rectangle. Because i'm looking for a rectangle to bound a connected component using the corner coordinates...
Image Analyst
Image Analyst am 28 Sep. 2012
No, bwboundaries gives you the actual tortuous shape of the boundary. If you want the bounding box, ask regionprops for BoundingBox, like I illustrate in my demo.
Ryan
Ryan am 28 Sep. 2012
If you are looking for the rectangular bounding box, then use Image Analyst approach. Utilize regionprops(), it's a fantastic analysis tool. If you are looking for the actual free-form perimeter of a shape, then bwboundaries() would be better.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by