#color-space #color-palette #palette #k-means #color-themes #themes #oklab

okolors

Create color palettes from images by performing k-means clustering in the Oklab color space

9 releases (breaking)

0.7.0 Mar 21, 2024
0.6.0 Feb 8, 2024
0.5.1 Oct 28, 2023
0.4.0 Aug 8, 2023
0.1.1 May 18, 2023

#322 in Images

Download history 1/week @ 2024-02-05 169/week @ 2024-02-19 20/week @ 2024-02-26 166/week @ 2024-03-18 177/week @ 2024-04-01

343 downloads per month

MIT/Apache

30KB
354 lines

Okolors

Crate Docs

Okolors generates high quality color palettes from an image for your theming needs. It does this by converting the image's pixels to the Oklab color space and then performing k-means clustering. By using a proper color space for color difference and a more accurate clustering algorithm, this helps to ensure that the generated palette is truly representative of the input image.

If you are looking for the CLI application, see the Github page.

Examples

Here are some examples of palettes generated by Okolors (using the default options).

Louvre

Louvre Louvre Palette

Hokkaido

Hokkaido Hokkaido Palette

Jewel Changi

Jewel Changi Jewel Changi Palette

Český Krumlov

Český Krumlov Český Krumlov Palette

Lake Mendota

Lake Mendota Lake Mendota Palette

Performance

Okolors is designed with performance in mind and should give fast results for even very large images. Below are the palette generation times as reported by the CLI application via the --verbose flag. 4 threads and the default options were used.

Image Width Height Unique Colors Time (ms)
Louvre 6056 4000 616101 63
Hokkaido 6000 4000 576339 57
Jewel Changi 6000 4000 400788 48
Český Krumlov 4608 3456 743552 51
Lake Mendota 3839 5758 467802 55
Louvre (25%) 1514 1000 238332 18
Hokkaido (25%) 1500 1000 262207 18
Jewel Changi (25%) 1500 1000 147678 11
Český Krumlov (25%) 1152 864 294989 20
Lake Mendota (25%) 960 1440 264149 18

License

Okolors is licensed under either

at your option.

Dependencies

~15MB
~142K SLoC