0

I have a numpy matrix of images with shape (50, 17500). Each image has shape (50, 50), so my matrix is like a long row of 350 grayscale images.

I want to use plt.imshow() to display those images. How do I change the dimension of the concatenated images matrix? Say reshaping the array to shape (1750, 500), which is 35 rows and 10 columns of images.

Some posts suggest to use np.reshape(), but if I use my_array.reshape((1750, 500)) the individual image in the new matrix is broken.

My question is how to reshape while preserving each individual (50,50) image?

Jay Wang
  • 2,650
  • 4
  • 25
  • 51
  • 2
    Would depend on how the images are stored in each row. But, for a general theory on such transformations, follow this - https://stackoverflow.com/questions/47977238/intuition-and-idea-behind-reshaping-4d-array-to-2d-array-in-numpy – Divakar Apr 01 '18 at 19:52
  • something like `np.concatenate(np.split(a, 35, axis=1))`, if efficiency (memory for copies) isn't important ? – f5r5e5d Apr 01 '18 at 23:04

0 Answers0