quantette
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 version2.10.34
. - The
Wu - sRGB
output was creating usingquantette
's fastest quantization method. The default number of bins was used (32
). - The
K-means - Oklab
output was creating usingquantette
's most accurate quantization method. A sampling factor of0.5
and a batch size of4096
was used.
All output images are undithered to better highlight differences.
Original Image
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
- the Apache License, Version 2.0 (see LICENSE-APACHE)
- the MIT license (see LICENSE-MIT)
at your option.