Guest User

Untitled

a guest
Jun 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. size[m_, pos_] := With[{comp = MorphologicalComponents[m, CornerNeighbors->False]},
  2. c = Extract[comp,pos];
  3. Count[comp,c,2]
  4. ]
  5.  
  6. SeedRandom[0]
  7. m = RandomInteger[1, {10,10}];
  8. MatrixPlot[m]
  9.  
  10. size[m, {5,1}]
Add Comment
Please, Sign In to add comment