Thank you for your reply. Wouldn’t that be like manually setting the colors to be in grayscale? I want to see the tensor image as it is, which is supposed to be grayscaled. Not sure if that make sense.
If your tensor doesn’t contain a color channel dimension the colormap is undefined and matplotlib will use its default one.
In case the tensor represents a real grayscale image, it would have a color channel size of 3 where all channels are equal.
This code shows the behavior:
x = torch.randint(0, 256, (100, 100, 1)).byte()
plt.imshow(x.numpy())
# create grayscale image
x = torch.cat((x, x, x), dim=2)
plt.imshow(x.numpy())
While single-channel images could be considered grayscale, matplotlib treats them as a matrix.