Image color clustering library for extracting N dominant colors from image
Project description
ImageToColors
ImageToColors is a Image color clustering library for extracting N dominant colors from image and provide list of extracted colors in HEX format.THe prime purpose of this library is to provide quick colors extraction. It has ExtractColors()
function which deals with clustering it also operate image according to their sizes for fast and secure clustering. It also provides HEXtoRGB()
conversion function.For Graphical analysis ImageToColors
gives you ClusterAnalaysis()
using this function one can analyze color values along with each color percentage present in given image
Installation
The easiest way to install the library is to execute
pip install ImageToColors
(note that you need network access to do it this way; if you do not have the pip tool installed -- see: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/).
Alternatively, you can download
_ the library source archive, unpack it, cd
to the unpacked directory and execute the following command
python setup.py install
It is also possible to use the library without installing it: as its code is contained in a single file (IMageToColors.py
), you can just copy it into your project.
Functions
ExtractColors()
It takes 2 arguments image
and cluster value
which is nothing but the integer value for number of colors want to extract.ExtractColors()
takes any image having .jpg
, .jpeg
, .png
any one of them extension.It returns a list of hex color code list.
['#46a947', '#ed3723', '#0b66b5', '#af60a8', '#fbbf10']
HEXtoRGB()
It takes single HEX
colors list argument and convert returns a RGB
colors code list
[(70, 169, 71), (237, 55, 35), (11, 102, 181), (175, 96, 168), (251, 191, 16)]
ClusterAnalysis()
It takes extracted HEX
colors list and plot the donut graph showing color code and percentage of colors present in given image.
https://github.com/MayurSatav/ImageToColors/blob/master/ImageToColors/test/output.png
Usage
from ImageToColors.ImageToColors import *
img = "image.jpg" # .png or .jpg
clust = 5 # Cluster value nothing but the how many dominant colors user want to extract
#to print extracted colors list use ExtractColors() function
HEXlist= ExtractColors(img,clust)
print(HEXlist)
# To convert Hex color list to RGB use HEXtoRGB
RGBlist = HEXtoRGB(HEXlist)
print(RGBlist)
#For graphical analysis use ClusterAnalysis()
ClusterAnalysis(HEXlist)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Distributed under the MIT License. See for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ImageToColors-1.1.tar.gz
.
File metadata
- Download URL: ImageToColors-1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 369f24501d1e9bfdec58d61657f5764c74181360144da63e0fb6e27327a5d4e3 |
|
MD5 | c2d110f015c9512f38fd06b461ed64d8 |
|
BLAKE2b-256 | 63bfe357b942e108210aef298ba3033c0561263113c38d1af9ff1836025df1ec |
File details
Details for the file ImageToColors-1.1-py3-none-any.whl
.
File metadata
- Download URL: ImageToColors-1.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 307632992a89023e043abeed931c7305a740db2f0e3fd2d4d219fbfadbd6a49d |
|
MD5 | 6ad0dc853e483537e3e67909096757d5 |
|
BLAKE2b-256 | 57bb9497c5cad16a15ed633a3cf3adadef483e26c7d4f6cd588644f6d6ef3451 |