An open API service indexing awesome lists of open source software.

https://github.com/aurcode/sunglass-cli

Convert an image to a given color palette using Python. This script allows you to transform images by mapping their colors to a specified palette. The color distance is calculated using the CIEDE2000 algorithm.
https://github.com/aurcode/sunglass-cli

ciede2000 image-processing

Last synced: 5 months ago
JSON representation

Convert an image to a given color palette using Python. This script allows you to transform images by mapping their colors to a specified palette. The color distance is calculated using the CIEDE2000 algorithm.

Awesome Lists containing this project

README

          

# sunglass-cli

## Image Color Palette Converter

This Python script converts an input image to a specified color palette. The script utilizes the CIEDE2000 color difference algorithm to find the closest matching colors in the given palette.

### Usage:
1. Install the required Python libraries:
```
docker run --rm -it --name python -v .:/src python:3.10 bash
pip install pillow==10.0.1 colormath==3.0.0 numpy==1.22.0
```

2. Run the script with the following command-line arguments:
```
python image_color_converter.py input_image_path output_image_path --palette color1 color2 color3 ...
```
- `input_image_path`: Path to the input image.
- `output_image_path`: Path to save the output image.
- `--palette`: List of hex colors to use in the output image (optional).

### Example:
```
python /src/sunglass.py input.jpg output.jpg --palette ffffff 999999 555555 222222
python /src/sunglass.py /src/res/input.jpg /src/res/output.jpg
```

### Results:

![这是图片](./res/input.jpg "girl lake input")
![这是图片](./res/output.jpg "girl lake output")

Feel free to contribute, report issues, or suggest improvements!