Home > Back-end >  Reshaping numpy array without changing the data
Reshaping numpy array without changing the data

Time:05-14

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.

CodePudding user response:

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

np.moveaxis(arr, 0, 2)

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

  • Related