Octree quantization for Allegro

Color quantization is a process of converting a truecolor image to the paletted (8 bit) image. In Allegro, this handles get_optimized_palette function. Normally works well, but sometimes does not. E.g. this image (120 KiB) is converted into this. This is quite strange, because Allegro supports only palettes with 18 bits per color (6 bits per each of R, G, B -- heritage from the VGA days :-) ). And the picture has in this mode just 188 colors, so there shouldn't be any quantization at all. So the result should be this.

So I wrote my own quantization, classic octree algorithm. It's slower than the Allegro one, but is always good to have more quantization algorithms, because they may produce different results for the same image.

The whole implementation is just one file (+ header file), simply add it to your projects and enjoy. You can find it at Subversion repository or in the download area.

Technical articles about color quantization

Octree Color Quantization
A C++ implementation of the octree color quantization method
Color Quantization using Octrees
Color Quantization
Optimizing Color Quantization for ASP.NET Images
Median-Cut Color Quantization
NeuQuant: Fast High-Quality Image Quantization

SourceForge.net Logo