1from matplotlib import pyplot as plt
2import cv2
3
4img = cv2.imread('/Users/barisx/test.jpg')
5gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
6
7plt.imshow(gray)
8plt.title('my picture')
9plt.show()
10# Problem, More Help -> linkedin.com/in/barisx
1# matplotlib interprets images in RGB format, but OpenCV uses BGR format
2
3# so to convert the image so that it's properly loaded, convert it before loading
4
5img = cv2.imread('filename.ext') # this is read in BGR format
6rgb_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # this converts it into RGB
7
8plt.imshow(rgb_img)
9plt.show()
10