Python PIL:Image.convert() 模式“L”为“1” - 如何更改值 127

问题描述 投票:0回答:1

我有一个只有灰色阴影的图像,我需要将其转换为只有黑白(“1”),但如果我只使用:

from PIL import Image
img = Image.open("img.jpg")
result = img.convert("1")
img.save("result.jpg")

值高于 127 的像素会转换为白色。有没有办法更改此边框,例如更改为 220,以便仅显示最亮的像素?谢谢你

python image python-imaging-library rgb image-conversion
1个回答
0
投票

查看文档。 您需要为您的用例使用“dither”参数。

© www.soinside.com 2019 - 2024. All rights reserved.