如何用PIL减少调色板 [英] How to reduce color palette with PIL
本文介绍了如何用PIL减少调色板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道我将如何减少PIL映像的调色板。我想减少一个图像的调色板到该图像中发现的5个突出的颜色。
I'm not sure how I would go about reducing the color palette of a PIL Image. I would like to reduce an image's palette to the 5 prominent colors found in that image. My overall goal is to do some basic color sampling.
推荐答案
这很容易,只需使用未记录的颜色参数:
That's easy, just use the undocumented colors argument:
result = image.convert('P', palette=Image.ADAPTIVE, colors=5)
我使用Image.ADAPTIVE避免抖动
I'm using Image.ADAPTIVE to avoid dithering
这篇关于如何用PIL减少调色板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文