-1

I am wanting to use python OpenCV for image processing. This is my original photo: enter image description here

I used the code below to load and show that image:

path = r"G:\3Y_individualProject\farm_colormap1.jpg"
colormap1 = cv2.imread(path)
plt.imshow(colormap1)
plt.show()

But it outputs an image of a slightly different color than the original image like this:enter image description here

Can someone tell me why there is such a difference? Thank you

Namfield
  • 43
  • 9
  • Use Image / PIL instead for images: https://stackoverflow.com/questions/5333244/how-to-display-a-jpg-file-in-python – Stefan Apr 08 '21 at 05:40

1 Answers1

1

Opencv uses the BGR color scheme instead of the RGB color scheme. So your red is probably blue and vice versa. You can fix this with:

img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
joostblack
  • 2,465
  • 5
  • 14