Explore Library
Code QuizIntermediate

Displaying an OpenCV Image

An image loaded with OpenCV shows swapped colors when displayed with matplotlib.

Codepython
import cv2
import matplotlib.pyplot as plt

img = cv2.imread('photo.jpg')
plt.imshow(img)
plt.show()  # colors look wrong (blue and red swapped)

What is the bug that causes the swapped colors?