Hi, i have a torch tensor that represent an RGB image (Channels x Height x Width), after i change it’s channels order to get an BGR image using a permute i’m not able to visualize it because, when change the type from Tensor to Numpy array and perform a reshape to change the dimension order to get ( H x W x C) the value from the channels mix together .
For example if the first channel is full of 1, the second channel full of 2 and the third channel full of 3, after the Numpy reshape every channel get some 1, 2 and 3.
here is the code:
x = #Torch Tensor RGB image (c, h, w)
permute = [2, 1, 0]
x = x[permute, :, :]
y = x.numpy()
c, h, w = y.shape
y = np.reshape(y, (h, w, c))
plt.imshow(y) #display a corrupted image
plt.show()