[iatile] [Up] [iameshgrid] | Image Information and Manipulation |
Implemented in Python.
>>> f = Numeric.array([[0,6,0,2],[4,0,1,8],[0,0,3,0]])
>>> print f
[[0 6 0 2] [4 0 1 8] [0 0 3 0]]
>>> i = Numeric.nonzero(Numeric.ravel(f))
>>> (x,y) = iaind2sub(f.shape, i)
>>> print x
[0 0 1 1 1 2]
>>> print y
[1 3 0 2 3 2]
>>> print f[x[0],y[0]]
6
>>> print f[x[4],y[4]]
8
def iaind2sub(dim, i): from Numeric import asarray i = asarray(i) x = i / dim[1] y = i % dim[1] return x, y
[iatile] [Up] [iameshgrid] | |