Skip to content

Spectrums: Optimize GMM params, UI, export palettes, improve clustering accuracy, and add customizable color schemes.

License

Notifications You must be signed in to change notification settings

XAheli/Spectrums

Repository files navigation

Spectrums - Color Palette Generator

Introduction

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.

Spectrums Palette Example

Features

  • 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.

K Means vs GMMs

Prerequisites

  • Python 3.9
  • Required Python libraries: numpy, scikit-learn, Pillow, matplotlib

Installation

  1. Clone this repository to your local machine:

    git clone https://github.com/XAheli/spectrums.git
    cd spectrums
    

Usage

  • 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.

Customization

  • 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.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

  • 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 ⭐!

About

Spectrums: Optimize GMM params, UI, export palettes, improve clustering accuracy, and add customizable color schemes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published