1.将RGB图像转换为灰度图像:

from PIL import Image
I = Image.open('F:\\pycharm\\picture_format\\data\\lena.jpg')
I.show()
L = I.convert('L')
L.show()

输出图像结果图为:



2.将RGB图像转换为1模式图像:

from PIL import Image
I = Image.open('F:\\pycharm\\picture_format\\data\\lena.jpg')
I.show()
L = I.convert('1')
L.show()
输出结果图为:



Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐