MATLAB: Locating similiar, connected entries inside matrix

bwlabelentriesImage Processing Toolboxmatrixsearch

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?

Best Answer

If you have the image processing toolbox, use bwlabel()