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()
输出结果图为: