1.将RGB图像转换为灰度图像:
from PIL import ImageI = Image.open('F:\\pycharm\\picture_format\\data\\lena.jpg')I.show()L = I.convert('L')L.show()
输出图像结果图为:
2.将RGB图像转换为1模式图像:
from PIL import ImageI = Image.open('F:\\pycharm\\picture_format\\data\\lena.jpg')I.show()L = I.convert('1')L.show()
输出结果图为:
如果觉得《基于python的图像格式转换(将RGB图像转换为灰度图像)》对你有帮助,请点赞、收藏,并留下你的观点哦!