gpt4 book ai didi

Python如何获取一张图像中使用的颜色列表

转载 作者:太空狗 更新时间:2023-10-30 00:20:12 25 4
gpt4 key购买 nike

Python如何获取一张图片中使用的颜色列表

我使用 PIL,我想要一个该图像中使用的颜色字典,包括颜色(键)和它使用的像素点数。

怎么做?

最佳答案

getcolors 方法应该可以解决问题。参见 the docs .

编辑:该链接已损坏。 Pillow 现在似乎是首选库,它是从 PIL fork 出来的。 New Docs

Image.open('file.jpg').getcolors() => a list of (count, color) tuples or None

关于Python如何获取一张图像中使用的颜色列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4643847/

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