Hi,
I'd like to quickly create a labelled grid to overlay on an array and use
as labels (eg scipy.ndimage.sum takes a labels option to calculate
statistics using a different array as a mask. My attempts to quickly
produce said masks work, but are a bit embarrassing...
*a = np.zeros((100, 100), dtype=np.int)*
*cnt = 0*
*for i in xrange(20): *
* for j in xrange(20):*
* cnt += 1*
* a[(i*5):((i+1)*5), (j*5):((j+1)*5)] = cnt*
So the above works, but it quickly gets cumbersome with large arrays, and
arrays where the ratio between how many cells in the finer array to the
coarser array. Is there some "keys in hand" solution for this problem?
Thanks!
Jose