gpt4 book ai didi

Python Imaging,如何将图像量化为 16 位深度?

转载 作者:太空宇宙 更新时间:2023-11-03 11:10:45 24 4
gpt4 key购买 nike

我想使用 Python Imaging 将 24 位图像量化为 16 位色深。

PIL 曾经提供一种方法 im.quantize(colors, **options) 但是这已经被弃用了 out = im.convert("P", palette=Image.ADAPTIVE, colors=256)

不幸的是,256 是 im.convert() 将量化为的最大颜色数(仅限 8 位)。

如何使用 PIL(或类似工具)将 24 位图像量化为 16 位?

谢谢

最佳答案

您可能需要考虑将图像转换为 numpy 数组,执行量化,然后再转换回 PIL。

numpy 中有模块可以与 PIL 图像相互转换。

关于Python Imaging,如何将图像量化为 16 位深度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4345337/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com