grouping array
George Sakkis
gsakkis at rutgers.edu
Thu Sep 29 17:32:41 EDT 2005
<pkilambi at gmail.com> wrote:
> hi if I have an array
>
> say x = [[2,2,0,0,1,1],
> [1,1,0,0,1,1],
> [1,1,0,0,1,1]]
> I basically want to group regions that are non zero like I want to get
> the coordinates of non zero regions..as (x1,y1,x2,y2)
> [(0,0,2,1),(0,4,2,5)] which show the top left(x1,y1) and bottom
> right(x2,y2) corners of each group.hope i am clear.
>
> Thanks
I guess you imply rectangular regions only ? If not, what's the output supposed to be for
[[2,2,0,0,1,1],
[1,1,3,0,0,1],
[1,1,3,0,1,1]]
or
[[2,2,2,2],
[1,0,3,3],
[1,1,3,0]]
George
More information about the Python-list
mailing list