IlvQuantizer: The Image Color Quantization Class
IlvQuantizer is the abstract base class of all color conversion classes. It is used to convert true color images to indexed images of given numbers of colors. It defines basic functionality common to all Views quantizers such as dithering.
Subclasses must redefine the computeColorMap method to return an appropriate IlvColorMap.
It has two main subclass categories:
-
The first category uses a fixed colormap.
-
The second one computes a colormap from the input image.
Currently Views has four predefined quantizers:
-
The IlvFixedQuantizer remaps true color images to indexed ones according to a user specified colormap.
-
The IlvQuickQuantizer specializes the IlvFixedQuantizer with a predefined colormap distributed in the color cube with 3 bits for the red component, 3 bits for the green component and 2 bits for the blue component, leading to a 256 color map well distributed in the color cube.
-
The IlvNetscapeQuantizer specializes the IlvFixedQuantizer with a predefined colormap known as the Netscape colormap. This colormap has 216 entries. Images generated with this colormap are guaranteed not to dither in the Netscape web browser.
-
The IlvWUQuantizer computes a colormap from the input image using the Wu algorithm. This algorithm generates very accurate colormaps even with a low number of colors (see the quantize sample). It is, however, slower than the others.
Other methods for quantization not implemented in Views are Neural Nets and Octrees.
Sample code:
IlvWUQuantizer quantizer;
// bdata is an instance of an IlvRGBBitmapData
IlvIndexedBitmapData* idata = quantizer.quantizer(bdata, 64);