I am trying to convert a color image (RGB, 24 bit, png) to grayscale using OpenCV. But I am getting unexpected results. I have tried the following 3 approaches, which all give the same result.
Method 1:
img=cv2.imread(file)
img=cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
plt.imshow(img)
temp=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(temp)
Method 2:
img=cv2.imread(file)
plt.imshow(img)
temp=cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
plt.imshow(temp)
Method 3:
img=cv2.imread(file,0)
img=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(img)
The original image is:

The image I am getting after the above conversions is:

I assume the problem lies in the channels (BGR being default for OpenCV imread). I need a proper grayscale image. Any help is appreciated. Thank You!
cmap='gray'else you get the Viridis colormap.