图像文件中原色的确定。
primarycolors的Python项目详细描述
图像文件中原色的确定。
要求
- Python(>;=2.7.0)
- 六
- scipy
- 努比
- 枕头
安装:
$ sudo pip install primarycolors
用法:
>>> from primarycolors import PrimaryColors >>> >>> # `image` - a path to image, >>> # `max_colors` - the maximum number of colors in the resulting. >>> im = PrimaryColors(image='Lenna.png', max_colors=5) >>> >>> # The primary colors in the RGB hexadecimal list. >>> im.hex ['621b43', '9e4257', 'e5bca5', 'd6877b', 'cb6161'] >>> im.web ['#621b43', '#9e4257', '#e5bca5', '#d6877b', '#cb6161'] >>> # The primary colors in the RGB integer list. >>> im.rgb [[ 98, 27, 67], [158, 66, 87], [229, 188, 165], [214, 135, 123], [203, 97, 97]] >>> >>> # An array of primary colors with the frequency coefficients. >>> im.sorted_colors [('cb6161', 0.24160000000000001), ('d6877b', 0.2412), ('621b43', 0.2016), ('9e4257', 0.1908), ('e5bca5', 0.12479999999999999)] >>> im.hsl [(326, 56.799999999999997, 24.509803921568629), (346, 41.071428571428569, 43.921568627450981), (21, 55.172413793103459, 77.254901960784323), (7, 52.601156069364166, 66.078431372549019), (0, 50.47619047619046, 58.823529411764696)]
类似命令行工具
$ pcolor -i Lenna.png -w #d68578 #c66162 #9d4459 #e3b7a2 #69234a $ cat Lenna.png | pcolor -r [157, 68, 89] [227, 183, 162] [214, 133, 120] [105, 35, 74] [198, 97, 98]
许可证:
PrimaryColors是免费软件:您可以重新分发和/或修改它 根据由 自由软件基金会,或者许可证的第3版,或者 任何更新版本。
原色的分布是希望它有用, 但没有任何保证;甚至没有 适销性或适合某一特定目的的适销性。见 GNU通用公共许可证了解更多详细信息。
你应该收到GNU通用公共许可证的副本 以及原色。如果没有,请参阅http://www.gnu.org/licenses/。