探明PIL库函数convert各种效果

实验代码:

from PIL  import Image#读图片 转化图像
import matplotlib
matplotlib.use('Agg')#为了能保存图片
import matplotlib.pyplot as plt#显示图片

mode = ['1', 'L', 'P', 'RGB', 'RGBA', 'CMYK', 'YCbCr', 'I', 'F']
img = Image.open('5.jpg')
plt.imshow(img)
plt.show()
print('the original finished!')
for one_mode in mode:
    img = Image.open('5.jpg')
    img = img.convert(one_mode)
    plt.imshow(img)
    plt.show()
    plt.savefig(one_mode + '.jpg')
    print(one_mode + ' mode convert finished!')
    

the original picture:

the original picture

convert('1'):

convert('1') picture

convert('L'):

convert('L') picture
convert('P'):

convert('P') picture
convert('RGB'):

convert('RGB') picture
convert('RGBA'):

convert('RGBA') picture
convert('CMYK'):

convert('CMYK') picture
convert('YCbCr'):

convert('YCbCr') picture
convert('I'):

convert('I') picture
convert('F'):

convert('F') picture

该博客以 Python图像处理库PIL-convert()函数(https://blog.csdn.net/chris_pei/article/details/78261922)博客作为依据,来讨论convert()函数的作用,观察图片(所以会有错误)现在能大略知道,

'F', 'l', 'L'是对原图片做灰度值转化;

’1‘在上述博客讲得挺好的,当成了黑色像素的密度处理;

除'P'外,其余方式都对原多彩图片没做改动。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值