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

Ric*_*ich 5 python imaging python-imaging-library

我想使用 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 位?

谢谢

pis*_*lis 3

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

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