What's the difference between mpimg.imread and plt.imread when I read an image with Python?
Question:
I’m trying to read an image, and I found that both following sentences are okay, so what’s the difference?
import matplotlib.pyplot as plt
img = plt.imread("1.jpg")
or
import matplotlib.image as mpimg
img = mpimg.imread('1.jpg')
Answers:
Based off of the source for matplotlib.pyplot.imread, it’s just an alias for matplotlib.image.imread
.
I’m trying to read an image, and I found that both following sentences are okay, so what’s the difference?
import matplotlib.pyplot as plt
img = plt.imread("1.jpg")
or
import matplotlib.image as mpimg
img = mpimg.imread('1.jpg')
Based off of the source for matplotlib.pyplot.imread, it’s just an alias for matplotlib.image.imread
.