常用模块
- 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()