Locating similiar, connected entries inside matrix
1 view (last 30 days)
Show older comments
Imagine having a logical matrix, with all zeroes, except a few separated islands of ones. Like this:
[0 0 0 0 1 0 0 0 0 1;...
0 0 0 1 1 1 0 0 1 1;...
0 0 0 1 1 0 0 0 1 1;...
0 0 0 0 0 0 0 0 0 0;...
0 0 0 0 0 0 0 0 0 0;...
0 0 0 0 1 1 0 0 0 0]
I can locate the row and column pairs for all the ones, but how to I get them divided into the three corresponding groups?
0 Comments
Accepted Answer
Walter Roberson
on 22 Dec 2012
If you have the image processing toolbox, use bwlabel()
2 Comments
Image Analyst
on 23 Dec 2012
Yes, but then what? I'm sure that's not the final step. What are you going to do next? The usual thing is to call regionprops() to make measurements of the individual regions. With later versions of MATLAB, you can just pass the binary matrix into regionprops() directly and bypass bwlabel().
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!