PIL
PIL(Python Imaging Library)是Python图像处理模块,支持多种格式,提供强大图像处理能力,可通过pip安装,PIL仅支持到Python 2.7,但pillow完美支持Python3,pillow实在PIL基础上创建的兼容版本,可以直接安装pillow。
如果安装了anaconda可以直接使用pillow。
pip install pillow
简单操作
如果安装了Anaconda3,可以在\Anaconda3\Lib\site-packages\PIL查看具体模块。
在windows环境下im.show使用windows自带的图像显示,可以使用matplotlib显示图像
以下代码可以改变plt.imshow(img12)中的参数查看图像效果
from PIL import Image
im = Image.open('C:\\Users\\WilliamZhang\\pythonLearn\\1.png')
im.show();
print(im.format)
print(im.size)
print(im.getpixel((100,50)))
print(im.histogram())
from PIL import Image
from random import randint as rint
img = Image.open('C:\\Users\\WilliamZhang\\pythonLearn\\test.bmp');
for w i