Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size[m_, pos_] := With[{comp = MorphologicalComponents[m, CornerNeighbors->False]},
- c = Extract[comp,pos];
- Count[comp,c,2]
- ]
- SeedRandom[0]
- m = RandomInteger[1, {10,10}];
- MatrixPlot[m]
- size[m, {5,1}]
Add Comment
Please, Sign In to add comment