Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pablonoya/dominantcolors
Extract dominant colors from an image using K-means and adjust them to have a defined contrast ratio
https://github.com/pablonoya/dominantcolors
dominant-colours-recognition machine-learning python
Last synced: 18 days ago
JSON representation
Extract dominant colors from an image using K-means and adjust them to have a defined contrast ratio
- Host: GitHub
- URL: https://github.com/pablonoya/dominantcolors
- Owner: pablonoya
- License: gpl-3.0
- Created: 2023-08-17T23:09:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-23T04:37:06.000Z (about 2 months ago)
- Last Synced: 2024-10-11T02:52:11.095Z (about 1 month ago)
- Topics: dominant-colours-recognition, machine-learning, python
- Language: Python
- Homepage:
- Size: 633 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dominantcolors
Gets the dominant colors from an image and modifies them to generate a palette with a suitable contrast ratio. Receives the image path and prints 3 hexadecimal colors.
It was initially intended for the media player widgets on my [AwesomeWM config](https://github.com/pablonoya/awesomewm-configuration), but it can be used for other purposes.
The first two colors are applied to the popup: one for the background and the other for the UI components. As my theme is dark, the most dominant color is blended with a background color to darken it.
![Popup](./screenshots/popup.webp)
The third color is the accent color for the radial progress bar in top bar.
![Top bar](./screenshots/bar.webp)
## Installation
### Using pipx
```shell
pipx install git+https://github.com/pablonoya/dominantcolors.git
```### Using poetry
```shell
git clone https://github.com/pablonoya/dominantcolors
cd dominantcolors
poetry install
```## Usage
```shell
$ dominantcolors [OPTIONS] /path/to/image
#d1dbe7
#3b6b92
#d1dbe7
``````
$ dominantcolors --help
Usage: dominantcolors [OPTIONS] IMAGE_PATHExtract dominant colors from IMAGE_PATH
Options:
-c, --target-contrast FLOAT Target contrast ratio [default: 3.0]
--bg-popup TEXT Background color of popup [default: #232A31]
-a, --alpha INTEGER RANGE Alpha value for blending with background color
[default: 208; 0<=x<=255]
--bg-topbar TEXT Background color of topbar [default: #303942]
--help Show this message and exit.
```