Bounding box on clusters in a 2D list

superprad at gmail.com superprad at gmail.com
Sun Apr 24 12:56:23 EDT 2005


hi Bearphile! That really gives me an idea.Thanks much for that. Yes as
you said the algorithm reaches a maximium recursion depth for larger
sets i tried.I still have a question. if
m = [[0,0,0,0],[0,1,1,0,0],[0,0,1,0,0],[0,0,0,0]]

all it does is count the number of 1's and return us the number in that
cluster. But if I want the box to be considered as one cluster as
   [[0, 0, 0, 0, 0],
        +-----+
     [0,|1, 1,|0, 0],
         |        |
     [0,|0, 1,|0, 0],
        +-----+
     [0, 0, 0, 0, 0]]


because it could be that the 0 in between the cluster of ones is a part
of the group.So the area of this boundingbox is 4 rather than 3. Do you
see where I am heading




More information about the Python-list mailing list