#quantization #palette #color #dither #kmeans

quantette

A fast and high quality image quantizer and palette generator. Supports the CIELAB, Oklab, and sRGB color spaces.

2 releases

0.1.1 Oct 28, 2023
0.1.0 Oct 25, 2023

#438 in Images

Download history 17/week @ 2023-11-02 17/week @ 2023-11-09 18/week @ 2023-11-16 19/week @ 2023-11-23 20/week @ 2023-11-30 17/week @ 2023-12-07 21/week @ 2023-12-14 19/week @ 2023-12-21 7/week @ 2023-12-28 9/week @ 2024-01-04 5/week @ 2024-01-11 5/week @ 2024-01-18 8/week @ 2024-01-25 12/week @ 2024-02-01 39/week @ 2024-02-08 35/week @ 2024-02-15

94 downloads per month
Used in okolors

MIT/Apache

225KB
4K SLoC

quantette

Crate Docs

quantette is a library for fast and high quality image quantization and palette generation. It supports the sRGB color space for fast color quantization but also the CIELAB and Oklab color spaces for more accurate quantization. Similarly, quantette's k-means color quantizer gives high quality results while the included Wu color quantizer gives fast but still quite good results.

In some critical locations, quantette makes use of SIMD (via the wide crate). Consider enabling the avx or avx2 target features for a noticeable speed up if your target architecture supports these features. If the threads cargo feature is enabled, multi-threaded versions of most functions become available for even greater speed up.

Examples

Below are some examples of quantette in action. The dissimilarity between the each image and the original is reported in the tables below using dssim (lower numbers are better). Each table starts with output from GIMP as a comparison.

Each output image was created like so:

  • The GIMP output was creating using Image > Mode > Indexed with GIMP version 2.10.34.
  • The Wu - sRGB output was creating using quantette's fastest quantization method. The default number of bins was used (32).
  • The K-means - Oklab output was creating using quantette's most accurate quantization method. A sampling factor of 0.5 and a batch size of 4096 was used.

All output images are undithered to better highlight differences.

Original Image

Calaveras

16 Colors

Method DSSIM Result
Gimp 0.06368717
Wu - sRGB 0.04014392
K-means - Oklab 0.02632949

64 Colors

Method DSSIM Result
Gimp 0.01730340
Wu - sRGB 0.01256557
K-means - Oklab 0.00638550

256 Colors

Method DSSIM Result
Gimp 0.00488789
Wu - sRGB 0.00330477
K-means - Oklab 0.00160596

License

quantette is licensed under either

at your option.

Dependencies

~14MB
~130K SLoC