There is a similar question in Python, but I am asking about a Julia version.
I have a multidimensional array with shape img = (3, 64, 64), which represents an image with the first dimension being RGB. I want to use plt.imshow(img) to show the image in Jupyter Notebook, but plt.imshow takes an array with the shape (64, 64, 3). So,
is there any built-in function which can convert img without changing the order of pixels?
Notice: reshape(img, (64, 64, 3)) does not work. I have tried this and not get the original image.
I have written a nested for loop to illustrate what I want:
# Suppose img has been created
img_reshaped = zeros(size(img)[2], size(img)[3], size(img)[1])
for i in 1: size(img)[2]
for j in 1: size(img)[3]
for k in 1: size(img)[1]
img_reshaped[i,j,k] = img[k,j,i]
end
end
end
plt.imshow(test_img)
The for loop above gives
while reshape(img, (64, 64, 3)) gives
which is not desired.

