Python常用的第三方模块之【PIL库】支持图像存储、处理、显示和图像融合等

        PIL是用于图像处理的第三方库,它支持图像存储、处理和显示等操作。

安装命令

pip install pillow

示例:图像的颜色交换

原图:

from PIL import Image
im=Image.open('Google.jpg')
# print(type(im),im) #<class 'PIL.PngImagePlugin.PngImageFile'> <PIL.PngImagePlugin.PngImageFile image mode=RGB size=1172x514 at 0x1258C8C20>

#提供RGB图像的颜色通道,返回结果是图像的副本
r,g,b=im.split()
print(r) #<PIL.Image.Image image mode=L size=1172x514 at 0x12E9A0D70>
print(g) #<PIL.Image.Image image mode=L size=1172x514 at 0x12E93EFD0>
print(b) #<PIL.Image.Image image mode=L size=1172x514 at 0x12E93F110>

#合并通道
om=Image.merge('RGB',(r,b,g))
om.save('changleColor_Google.jpg')

颜色更新后的图:

想更深入学习,可参考博客Python 图像处理 PIL 第三方库详细使用教程(更新中)-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值