Python-读取并显示图片

读取并显示图片可以使用pillow模块,pillow模块的安装:
 

pip install Pillow

在读取图片时,Windows系统要注意路径问题,使用'\\' 代替'\'

from PIL import Image
img = Image.open('E:\\a.jpg')
img.show()

Python-读取并显示图片_第1张图片

这样的显示方式,需要调用系统中的图片显示程序。也可以借助matplotlib库实现python环境下的显示:

from PIL import Image
import matplotlib.pyplot as plt

img = Image.open('E:\\a.jpg')

plt.imshow(img)
plt.show()

Python-读取并显示图片_第2张图片 

 

你可能感兴趣的:(Python-读取并显示图片)