Finding pixels in connected component
Ältere Kommentare anzeigen
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
Weitere Antworten (1)
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
am 28 Sep. 2012
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
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.
Kategorien
Mehr zu Region and Image Properties finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!