Spectrums is a Python utility that allows you to create beautiful color palettes based on an input image. This project was created as a practice exercise to gain a deeper understanding of Gaussian Mixture Models (GMMs) and color analysis. It uses GMMs to cluster colors from an image and presents them in a visually appealing palette.
- Generate color palettes from input images.
- Utilizes Gaussian Mixture Models (GMMs) for color clustering.
- Sorts colors based on a custom ranking that considers hue, saturation, and perceived brightness.
- Provides a graphical representation of the generated color palette.
- Python 3.9
- Required Python libraries:
numpy
,scikit-learn
,Pillow
,matplotlib
-
Clone this repository to your local machine:
git clone https://github.com/XAheli/spectrums.git cd spectrums
-
Ensure you have an image (e.g., IMG_1969 copy.jpg) that you want to create a color palette from. You can replace this file with your own image.
-
Open the spectrums.py script in a text editor and modify the image_path variable to specify the path to your image.
-
Adjust the num_colors variable to set the number of colors you want in the palette.
-
Run the script:
python spectrums.py
-
The script will generate a graphical representation of the color palette and display it using Matplotlib. You can adjust the figure size and layout in the script as needed.
-
The script will also print the color labels and their RGB values to the console.
- You can customize the script further by adjusting the coefficients in the perceived_brightness function to change how brightness is calculated.
- Modify the ranking in the hsp_rank function to influence the sorting of colors based on your preferences.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- The custom color ranking algorithm in this project is inspired by the work of Darel Rex Finley (source).
Enjoy creating beautiful color palettes with Spectrums! If you find this project useful, don't forget to give it a star ⭐!