Crates.io | colorbuddy |
lib.rs | colorbuddy |
version | 0.1.6 |
source | src |
created_at | 2023-02-08 02:31:13.820555 |
updated_at | 2023-02-15 12:11:28.142287 |
description | Generates a color palette based on an image. |
homepage | |
repository | https://github.com/adamazing/colorbuddy.git |
max_upload_size | |
id | 779276 |
size | 53,818 |
Color Buddy is a command line tool that can generate a color palette from an image.
cargo install colorbuddy
colorbuddy --help
Produces the following output:
Generates a color palette based on an image.
Usage: colorbuddy [OPTIONS] <IMAGE>
Arguments:
<IMAGE>
Options:
-m, --quantisation-method <QUANTISATION_METHOD>
[default: k-means] [possible values: median-cut, k-means]
-n, --number-of-colors <NUMBER_OF_COLORS>
[default: 8]
-o, --output <OUTPUT>
-t, --output-type <OUTPUT_TYPE>
[default: original-image] [possible values: json, original-image, standalone-palette]
-p, --palette-height <PALETTE_HEIGHT>
[default: 256]
-w, --palette-width <PALETTE_WIDTH>
-h, --help
Print help information
-V, --version
Print version information
The default options will result in:
Generate JSON containing the 8 most prevalent colors in the image:
colorbuddy --output-type json original-image.jpg
Output the original images with a palette of the 5 most prevalent colors along the bottom:
colorbuddy --number-of-colors 5 --output-type original-image.jpg another-image.jpg
Specify the height of the palette as a percentage of the original image's height:
colorbuddy --palette-height 20% original-image.jpg
Specify a width, height, and the standalone-palette output height to create a standalone palette image:
colorbuddy --palette-height 50px --palette-width 500 original-image.jpg
Median Cut quantization is a method used in image processing to reduce the number of colors used in an image. The goal is to represent the original image using a smaller color palette, while preserving as much of the visual information as possible.
Think of it like this: imagine you have a box of crayons, and you want to reduce the number of crayons you have while still being able to color a picture. The Median Cut quantization method would help you choose a smaller set of crayons that represent the range of colors used in your picture, so that you can still color a picture that looks similar to the original.
In Median Cut quantization, the first step is to divide the color space of the image into smaller sections. This is done by finding the median color value in each section and dividing the section in two based on this median value. This process is repeated until you have the desired number of colors in your palette.
K-means clustering is a machine learning technique used for grouping data into "clusters" based on similarities between the data points.
Think of it like this: imagine you have a bunch of different colored balls, and you want to group them into a few different baskets based on their color. K Means Clustering is a way for the computer to automatically separate the balls into baskets such that each basket contains balls of similar color.
The "K" in K Means refers to the number of baskets you want to create. So, you can choose to have 2 baskets, 3 baskets, or even 10 baskets, depending on how many groups you want to create.
Or: "When should I use one method over the other?"
K-means clustering results in a palette of the most common colours in the image, whereas median cut quantisation results in a palette of representative colours.
Experiment with what works best for your application!
This is a personal, unpaid, open source project. If you encounter a bug or other issue, require help or the addition of some new feature, please feel free to raise an Issue on GitHub. I will endeavour to respond in a relatively timely manner but provide no guarantees.
👨 Adam Henley (he/him)
Give a ⭐️ if this project helped you!