imgpd

Fast and accurate image RGB palette detector by Eugene Gourieff


License
GPL-3.0
Install
pip install imgpd==0.3.0

Documentation

Image Palette Detector

This is a simple python application that detects dominant color of your source image and create an output palette combined with the source image.

Guide:
Interface
Installation
Usage
Example

Interface

Application has 3 types of the user-interface:

  • the comand-line with arguments:

cl-mode

  • the dialog with no-GUI:

no-gui-dialog-mode

  • the dialog with GUI:

gui-dialog-mode

Installation

Just download or clone the repo

git clone https://github.com/Gourieff/img-palette-detector

and install requirements:

pip install -r requirements.txt

or

pip install opencv-python; colorthief; argparse; pysimplegui

Usage:

python ipd.py -i "C:\my super images\image_file_name.png" -m "3" -c "5"

Where optional arguments are:

  -i PATH_TO_IMAGE  Path to the image file
  -m METHOD         Method to build the Palette: 1 - OpenCV based method, 2 - ColorThief based method, 3 - Both
  -c COLORS_COUNT   How much colors on the Palette must be: 2 - is minimum, don't type too much, 3-7 is optimal
  -d                To run Application in the dialog mode w/o GUI

or just type for help:

python ipd.py -h

You can also run the App in the dialog mode

with GUI:

python ipd.py

without GUI:

python ipd.py -d

Then you see the dialog:

> How to build Palette? (Choose 1, 2 or 3)
> 1 - OpenCV based method
> 2 - ColorThief based method
> 3 - Both

Type 1, 2 or 3 and proceed to the next step:

> Type the filename or path (ex.: image.png):

Type a full or a relative path to your image or just an image name if your image is at the same folder:

C:\my super images\image_file_name.png

or

/home/user/images/image_file_name.png

or

image_file_name.png

Proceed to the next step:

> How much colors on the Palette must be? (2 - is minimum, don't type too much, 3-7 is optimal)

And type how much color must be in the Palette, for example:

5

Then wait a little for the result.

Example:

$ python ipd.py -d
> How to build Palette? (Choose 1, 2 or 3)
> 1 - OpenCV based method
> 2 - ColorThief based method
> 3 - Both
>> 3
> Type the filename or path (ex.: image.png):
>> sample/image.png
> How much colors on the Palette must be? (2 - is minimum, don't type too much, 3-7 is optimal)
>> 5

Source Image:

image

Output Result:

Method 1:

image_5-colors-palette_method-1

Method 2:

image_5-colors-palette_method-2

For most images Method 1 is more accurate, but for some images (as shown above) Method 2 will give you a better result, so I recommend to use 'Both' and then choose which is better.