python的matplotlib.pyplot显示图片
程序员文章站
2022-03-02 08:13:47
...
matplotlib.pyplot docs :https://matplotlib.org/api/pyplot_summary.html
用matplotlib库显示图片
'''
imread(*args, **kwargs) Read an image from a file into an array.
imsave(*args, **kwargs) Save an array as in image file.
imshow(X[, cmap, norm, aspect, …]) Display an image on the axes.
'''
import matplotlib.pyplot as plt
img = plt.imread('G:\\picture\\2.jpg')
plt.imshow(img)
plt.show()
matplotlib与PIL.Image结合显示
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from PIL import Image
img1=Image.open('G:\\picture\\1.jpg')
npimg1=np.array(img1)
plt.imshow(npimg1)
plt.show()
上一篇: Lua中的变量类型与语句学习总结