Bounding box on clusters in a 2D list

superprad at gmail.com superprad at gmail.com
Sat Apr 23 16:17:55 EDT 2005


If I have

ex: x = [[1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0],
         [1,1,1,0,1,1,0,0,0,0,0,1,1,1,1,0,0,0],
         [1,1,1,0,1,1,1,0,1,1,0,1,1,1,0,0,0,0],
         [0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0]]
what I want is a boundingbox over the region where we find clusters of
1's.So for instance in the above list first 3 roes and colums have 1's
so the area of that box is 3x3
so my final array should have an array of approx areas of clusters of
1's like
area = [ 9,4 ....]
Hope I am clear with my question.




More information about the Python-list mailing list