Python PIL将PNG图像转换为黑白图像

时间:2017-07-23 11:23:47

标签: python image python-imaging-library pillow

我正在尝试将一对深度和RGB图像与Python PIL 组合在一起:

Depth Image RGB Image

这是简单的代码:

image1 = Image.open('1.png').resize((256, 256))
image2 = Image.open('2.jpg').resize((256, 256))
new_image = Image.new('RGB', (512, 256))

x_offset = 0
new_image.paste(image1, (x_offset, 0))
x_offset += image1.size[0]
new_image.paste(image2, (x_offset, 0))

new_image.save('3.jpg',image2.format)

但是当使用 PIL 时,它会自动将深度图像转换为黑白版本:

Final Image

如何以原始形式保存深度图像?

0 个答案:

没有答案
相关问题