필터 지우기
필터 지우기

Finding pixels in connected component

조회 수: 3 (최근 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
Image Analyst
Image Analyst 2012년 9월 27일
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 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
Image Analyst
Image Analyst 2012년 9월 28일
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 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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by