#quant #networking #color #alpha

color_quant

Color quantization library to reduce n colors to 256 colors

3 stable releases

Uses old Rust 2015

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

#470 in Images

Download history 263452/week @ 2023-10-20 282936/week @ 2023-10-27 271325/week @ 2023-11-03 295542/week @ 2023-11-10 233009/week @ 2023-11-17 208597/week @ 2023-11-24 207311/week @ 2023-12-01 259724/week @ 2023-12-08 257613/week @ 2023-12-15 136194/week @ 2023-12-22 203640/week @ 2023-12-29 267589/week @ 2024-01-05 238010/week @ 2024-01-12 238170/week @ 2024-01-19 237205/week @ 2024-01-26 220496/week @ 2024-02-02

979,082 downloads per month
Used in 3,395 crates (15 directly)

MIT license

19KB
345 lines

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();

lib.rs:

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();

No runtime deps