I have an array of images where each image is stored as the following dimension
(3, 32, 32)
if I wanted to show an image using
plt.imshow(img)
then I am getting the following error:
TypeError: Invalid shape (3, 32, 32) for image data
I understand why I am getting this error, because according to imshow documentation, it takes an array of shape
(M, N), or (M, N, 3), or (M, N, 4)
How can I convert the image such that it has the required dimensions without losing any of its data?
Thanks!
Try transposing: img.T
This will reverse the order of the dimensions, making it (M,N,3)
.