| This OperationDescriptor defines the "ColorQuantizer"
operation.
This operation generates an optimal lookup table (LUT) based on
the provided 3-band RGB source image by executing a color
quantization algorithm. This LUT is stored in the property
"JAI.LookupTable" that has a type of LookupTableJAI .
Thus, it can be retrieved by means of getProperty .
This LUT can be further utilized in other operations such as
"errordiffusion" to convert the 3-band RGB image into a high-quality
color-indexed image. The computation of the LUT can be deferred by
defining a DeferredProperty from the property
"JAI.LookupTable" and providing that as the parameter value for
"errordiffusion". This operation also creates a color-indexed
destination image based on the nearest distance classification (without
dithering). However, the quality of this classification result may
not be as good as the result of "errordiffusion".
The supported source image data type is implementation-dependent.
For example, the Sun implementation will support only the byte type.
The data set used in the color quantization can be defined by
the optional parameters xPeriod , yPeriod
and ROI . If these parameters are provided, the pixels in
the subsampled image (and in the ROI) will be used to compute the
LUT.
Three built-in color quantization algorithms are supported by
this operation: Paul Heckbert's median-cut algorithm, Anthony Dekker's
NeuQuant algorithm, and the Oct-Tree color quantization algorithm of
Gervautz and Purgathofer.
The median-cut color quantization computes the 3D color histogram
first, then chooses and divides the largest color cube (in number of pixels)
along the median, until the required number of clusters is obtained
or all the cubes are not separable. The NeuQuant algorithm creates
the cluster centers using Kohonen's self-organizing neural network.
The Oct-Tree color quantization constructs an oct-tree of the
color histogram, then repeatedly merges the offspring into the parent
if they contain a number of pixels smaller than a threshold. With the
equivalent parameters, the median-cut algorithm is the fastest, and the
NeuQuant algorithm is the slowest. However, NeuQuant algorithm can
still generate a good result with a relatively high subsample rate, which
is useful for large images.
In these three algorithms, the Oct-Tree algorithm is the most space
consuming one. For further details of these algorithms,
please refer to the following references:
Algorithm |
References |
Median-Cut |
Color Image Quantization for Frame Buffer
Display, Paul Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307
|
NeuQuant |
Kohonen Neural Networks for Optimal Colour Quantization,
Anthony Dekker, In Network: Computation in Neural Systems,
Volume 5, Institute of Physics Publishing, 1994, pp 351-367.
|
Oct-Tree |
Interactive Computer Graphics: Functional, Procedural, and
Device-Level Methods by Peter Burger and Duncan Gillis,
Addison-Wesley, 1989, pp 345.
|
The generated LUT may have fewer entries than expected. For
example, the source image might not have as many colors as expected.
In the oct-tree algorithm, all the offspring of a node are merged
if they contain a number of pixels smaller than a threshold. This
may result in slightly fewer colors than expected.
The learning procedure of the NeuQuant algorithm randomly goes
through all the pixels in the training data set. To simplify and
speed up the implementation, the bounding rectangle of the
provided ROI may be used (by the implementation) to define the
training data set instead of the ROI itself.
Resource List
Name | Value |
GlobalName | ColorQuantizer |
LocalName | ColorQuantizer |
Vendor | com.sun.media.jai |
Description | Generates an optimal LUT by executing a
color quantization algorithm, and a
color-indexed image by the nearest distance
classification. |
DocURL | http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ColorQuantizerDescriptor.html |
Version | 1.1 |
arg0Desc | The color quantization algorithm name. One of
ColorQuantizerDescriptor.MEDIANCUT,
ColorQuantizerDescriptor.NEUQUANT, or
ColorQuantizerDescriptor.OCTTREE |
arg1Desc | The maximum color number, that is, the expected
number of colors in the result image. |
arg2Desc | This is an algorithm-dependent parameter. For
the median-cut color quantization, it is the
maximum size of the three-dimensional
histogram.
For the neuquant color quantization, it is the
number of cycles. For the oct-tree color
quantization, it is the maximum size of the
oct-tree. |
arg3Desc | The ROI in which the pixels are involved into
the color quantization. |
arg4Desc | The subsample rate in x direction. |
arg4Desc | The subsample rate in y direction. |
Parameter List
Name | Class Type |
Default Value |
quantizationAlgorithm |
javax.media.jai.operator.ColorQuantizerType |
ColorQuantizerDescriptor.MEDIANCUT |
maxColorNum | java.lang.Integer |
256 |
upperBound | java.lang.Integer |
32768 for median-cut, 100 for neuquant,
65536 for oct-tree |
roi | javax.media.jai.ROI |
null |
xPeriod | java.lang.Integer |
1 |
yPeriod | java.lang.Integer |
1 |
See Also: javax.media.jai.ROI See Also: javax.media.jai.OperationDescriptor since: JAI 1.1.2 |