Locating similiar, connected entries inside matrix

1 view (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 22 Dec 2012
If you have the image processing toolbox, use bwlabel()
  2 Comments
Jeppe
Jeppe on 23 Dec 2012
That is exactly what I was looking for. Thank you
Image Analyst
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().

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!