Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mstfldmr/45d6e47bb661800b982c39d30215bc88 to your computer and use it in GitHub Desktop.
Save mstfldmr/45d6e47bb661800b982c39d30215bc88 to your computer and use it in GitHub Desktop.
from matplotlib import pyplot as plt
import cv2
img = cv2.imread('/Users/mustafa/test.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(gray)
plt.title('my picture')
plt.show()
@AliNiaz990487
Copy link

One more example for displaying a color image. Matplot lib expects img in RGB format but OpenCV provides it in BGR.

RGB_im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)

Screenshot from 2024-06-08 12-44-04
Screenshot from 2024-06-08 12-44-26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment