Reputation: 183
When I tried to convert an RGB image with OpenCV function cv2.cvtColor(), I got a green-like image.
I've converted the raw image read by OpenCV to RGB-format, again converted it to gray scale using cv2.cvtColor(), and tried to display it using pyplot.imshow() function.
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
plt.imshow(image)
Upvotes: 10
Views: 12372
Reputation: 23498
plt.imgshow()
uses a color map for a single-channel images. You have two possible solutions, convert your grayscale to rgb (basically duplicate the grayscale 3 times), or choose a proper colormap as explained here: https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html
Upvotes: 6