Divide numpy array

Posted by BandGap on Stack Overflow See other posts from Stack Overflow or by BandGap
Published on 2010-05-05T13:34:11Z Indexed on 2010/05/05 13:38 UTC
Read the original article Hit count: 210

Filed under:
|

Hi all

I have some data represented in a 1300x1341 matrix. I would like to split this matrix in several pieces (e.g. 9) so that I can loop over and process them. The data needs to stay ordered in the sense that x[0,1] stays below (or above if you like) x[0,0] and besides x[1,1].
Just like if you had imaged the data, you could draw 2 vertical and 2 horizontal lines over the image to illustrate the 9 parts.

If I use numpys reshape (eg. matrix.reshape(9,260,745) or any other combination of 9,260,745) it doesn't yield the required structure since the above mentioned ordering is lost...

Did I misunderstand the reshape method or can it be done this way?

What other pythonic/numpy way is there to do this?

© Stack Overflow or respective owner

Related posts about python

Related posts about numpy