常用模块
- PIL(Python Imaging Library)
- matplotlib.pyplot(注意有一个叫pylab的模块)
PIL
基本操作
打开图片,保存图片
引入模块
from PIL import Image
打开图片
im = Image.open("pathtoimg.png")
存储图片
im.save("pathtosave.png")
matplotlib.pyplot
联合使用
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
img = Image.open("pathtoimg.png")
im = np.array(img)
plt.imshow(im)
n = 3
x = plt.ginput(n)
print(x)
plt.show()
本文介绍了使用Python的PIL库进行图片的基本操作,包括图片的打开与保存,并通过matplotlib.pyplot展示图片及获取用户点击坐标。
2531

被折叠的 条评论
为什么被折叠?



