Home > Software design >  OpenCV is not graying an image with cv2.cvtColor when displayed with matplotlib
OpenCV is not graying an image with cv2.cvtColor when displayed with matplotlib

Time:09-09

I tried to gray an image but it does not work properly like it should. It just applied a kind of filter as you can see by using cv2.COLOR_BGR2GRAY function. Kindly someone help me to get over with this issue.

1

CodePudding user response:

Your issue is that you're using matplotlib to show your grayscale image. Matplotlib applies a colormap. By default that's a colorful one.

Add cmap="gray" in your imshow call: plt.imshow(img_gray, cmap="gray")

  • Related