songdairong / DominantColors

This is a small project which makes use of Clustering Algorithm, K-Means to create color clusters in input image. The color clusters are visualized using scatter plot and pie-chart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DominantColors

Synopsis

This is a small project which makes use of Clustering Algorithm, K-Means to create color clusters in input image. The color clusters are visualized using scatter plot and pie-chart. Both input image and number of clusters can be passed in as cmd argument. By default, for input image, it looks into "images" folder which has some sample images while the number of clusters is 5.

Installation

  1. Pillow
  2. Matplotlib
  3. Numpy
  4. collections
  5. scikit-learn
  6. Pandas
  7. webcolors
  8. math
  9. json
  10. argparse

Use Case

Android Developers, Web Developers or anyone looking to replicate a template face the problem of identifying the hex codes for colors used in the templates. This program will make their lives easier. They can load the template image in the program, set the number of clusters (No. of colors to be identified) and the program will return the hexcodes and name (actual/nearest) of the colors used in the image.

Output

3D Scatter Plot (different color clusters)

picture alt

PieChart distribution

picture_alt

Shortcomings

The name of colors may change with increasing/decreasing number of clusters. This is because the program uses the center of clusters to calculate the hex codes. For color names, it looks up in a JSON containing hexcodes and respective color names. If it is not able to find hex code in the JSON, it finds the nearest hex code (using Euclidean distance) and returns the name of that hex code. When we increase/decrease the number of clusters, the center of cluster changes. Because of that, hex code changes and eventually, the nearest hex code/color name.

Please find the Android App deployment of the program : https://play.google.com/store/apps/details?id=com.proxima.colorpixor

Contribution

Feel free to fork and submit bug fixes or new features. You can file bugs, suggestions, and feature requests through issues page.

About

This is a small project which makes use of Clustering Algorithm, K-Means to create color clusters in input image. The color clusters are visualized using scatter plot and pie-chart.


Languages

Language:Python 100.0%