sonido
sonido

Reputation: 63

Reshaping numpy array without changing the data

I'm trying to reshape an array of bitmap images that has a shape of (50,50,90000). How can I modify it so that I can get an array of (90000,50,50)? - I tried array.reshape(90000,50,50), or np.reshape(array, (90000,50,50), order='C' /'F'), but these options changed the order of the data so I couldn't get the images after using these.

Upvotes: 1

Views: 353

Answers (1)

Matt Hall
Matt Hall

Reputation: 8142

Try np.moveaxis, e.g. like so:

np.moveaxis(arr, 0, 2)

There's also np.swapaxes if that suits your needs better.

Upvotes: 1

Related Questions