开发者

Python Imaging, how to quantize an image to 16bit depth?

开发者 https://www.devze.com 2023-01-28 21:34 出处:网络
I would like to quantize a 24bit image to 16bit color depth using Python Imaging. PIL used to provide a method im.quantize(colors, **options) however this has been deprecated for ou开发者_StackOverfl

I would like to quantize a 24bit image to 16bit color depth using Python Imaging.

PIL used to provide a method im.quantize(colors, **options) however this has been deprecated for ou开发者_StackOverflow社区t = im.convert("P", palette=Image.ADAPTIVE, colors=256)

Unfortunately 256 is the MAXIMUM number of colors that im.convert() will quantize to (8 bit only).

How can I quantize a 24bit image down to 16bit using PIL (or similar)?

thanks


You might want to look into converting your image to a numpy array, performing your quantisation, then converting back to PIL.

There are modules in numpy to convert to/from PIL images.

0

精彩评论

暂无评论...
验证码 换一张
取 消