图像处理
python最常用的图像库PIL
用python来进行图像处理时,最常用的第三方库就是PIL(Python Image Library),他封装了Image
类以及一系列对图像进行修改的方法。具体操作可以看文档Pillow — Pillow (PIL Fork) 8.2.0 documentation
很多时候我们在处理图像的时候,会用到numpy的narray数组来表示像素点矩阵(如使用TensorFlow或PyTorch等进行人工智能的图像识别等),但
PIL.Image()
中的数据并不是这样的数据类型,应注意需要进行相应的转换。
python3安装PIL
1 | pip install pillow |
python2.x是用PIL,但到了python3.x,就要用pillow
图像类 PIL.Image()
使用Image()
打开一个图像,如下:
1 | from PIL import Image() |
对图像的各种修改操作
咕咕咕