Created
August 23, 2019 15:59
-
-
Save dazcona/180e8c6dd3a0e9e899bf9eedfaf8ae87 to your computer and use it in GitHub Desktop.
Display matplotlib RGB images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display matplotlib RGB images | |
# https://www.pyimagesearch.com/2014/11/03/display-matplotlib-rgb-image/ | |
# matplotlib: pyplot and mpimg to load and display our images | |
# plt.axis("off"): to remove the axes of the figure | |
# OpenCV: images are stored in BGR order rather than RGB! | |
# Matplotlib | |
import matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
image = mpimg.imread("chelsea-the-cat.png") | |
plt.axis("off") | |
plt.imshow(image) | |
plt.show() | |
# OpenCV | |
import cv2 | |
image = cv2.imread("chelsea-the-cat.png") | |
plt.axis("off") | |
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment