Skip to content

Gourieff/img-palette-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Palette Detector

This is a simple python application that detects dominant colors 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

You can install it as a package:

pip install imgpd

Or 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:

With cl-arguments:

If you use directly

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

If you use as a package

for Windows users:

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

for Linux/MacOS users:

imgpd -i /home/user/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 or imgpd -h

You can also run the App in the dialog mode:

with GUI:

python ipd.py or imgpd

(See the GUI images above at 'the dialog with GUI' section)

without GUI:

python ipd.py -d or imgpd -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:

$ imgpd -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.