Finding pixels in connected component

6 ビュー (過去 30 日間)
Muffin
Muffin 2012 年 9 月 27 日
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!

採用された回答

Image Analyst
Image Analyst 2012 年 9 月 27 日
編集済み: Image Analyst 2012 年 9 月 27 日
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 件のコメント
Muffin
Muffin 2012 年 10 月 10 日
Hey, thanks a lot, your tutorial was of help! I managed to draw my bounding boxes!

サインインしてコメントする。

その他の回答 (1 件)

Ryan
Ryan 2012 年 9 月 27 日
編集済み: Ryan 2012 年 9 月 27 日
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 件のコメント
Ryan
Ryan 2012 年 9 月 28 日
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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by