I am trying to get the shape of images in my custom data generator :
for j in range(len(image)):
img = np.array(image[j])
print(img.shape)
plt.imshow(img)
plt.show()
The img.shape
shows (128, 87)
without the third dimension, so I expect to see a grayscale image, while the plt.imshow(img)
shows the full-color image.
On the other hand, I converted grayscale to RGB using the following code:
def grayscale_to_rgb(input_image):
input_image = np.expand_dims(input_image, -1)
input_image_3_channel =input_image.repeat(3, axis=-1)
return input_image_3_channel
the image shape will be (128,87,3) but I see a grayscale image using plt.imshow(img).
I have already seen this question. What I understood is the grayscale image is still grayscale, but imshow
shows the default cmap
. So, how can I see the RGB image in color?