Skip to main content

Fast and accurate image RGB palette detector by Eugene Gourieff

Project description

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

You can also install it as a package:

pip install imgpd

Usage:

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

If you installed 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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgpd-0.3.0.tar.gz (20.7 kB view hashes)

Uploaded Source

Built Distribution

imgpd-0.3.0-py3-none-any.whl (20.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page