#color-quantization #networking #reduce

color_quant

Color quantization library to reduce n colors to 256 colors

4 stable releases

2.0.0 May 9, 2026
1.1.0 Oct 9, 2020
1.0.1 Jun 13, 2018
1.0.0 May 29, 2015

#550 in #networking

Download history 198542/week @ 2026-03-03 1387762/week @ 2026-03-10 1261909/week @ 2026-03-17 1254595/week @ 2026-03-24 1163954/week @ 2026-03-31 1282030/week @ 2026-04-07 1244126/week @ 2026-04-14 1277544/week @ 2026-04-21 1354976/week @ 2026-04-28 1323649/week @ 2026-05-05 1568725/week @ 2026-05-12 1585763/week @ 2026-05-19 1631884/week @ 2026-05-26 1553817/week @ 2026-06-02

6,555,700 downloads per month
Used in 4,743 crates (31 directly)

MIT license

22KB
370 lines

Color quantization library

This library provides a color quantizer based on the NEUQUANT

Original literature: Dekker, A. H. (1994). Kohonen neural networks for optimal colour quantization. Network: Computation in Neural Systems, 5(3), 351-367. doi: 10.1088/0954-898X_5_3_003

See also https://scientificgems.wordpress.com/stuff/neuquant-fast-high-quality-image-quantization/

Usage

let data = vec![0; 40];
let nq = color_quant::NeuQuant::new(10, 256, &data);
let indixes: Vec<u8> = data.chunks(4).map(|pix| nq.index_of(pix) as u8).collect();
let color_map = nq.color_map_rgba();

Color quantization library

This library provides a color quantizer based on the NEUQUANT quantization algorithm by Anthony Dekker.

Usage

let data = vec![0; 40];
let nq = color_quant::NeuQuant::new(10, 256, &data);
let indixes: Vec<u8> = data.chunks(4).map(|pix| nq.index_of(pix) as u8).collect();
let color_map = nq.color_map_rgba();

No runtime deps