I'm not sure myself. I have not done something like that before. But I
am sure that someone else did something like that somewhere on the net...
Samuel
This is a bit sideways answer, but since you are already in Java, you
can use ImageJ plugins to reduce color. The k-means info is here:
http://ij-plugins.sourceforge.net/plugins/segmentation/k-means.html
You want to use image produced by option: "Show clusters as centroid
value" (this is equivalent to color reduction). Note that the k-means
can be called trough API without ImageJ running. Note that you can
covert to a image stack in order color space, say L*a*b*, use the
k-means plugin, then convert result back to RGB
(http://ij-plugins.sourceforge.net/plugins/color/index.html).
The 3D Color Inspector plugin can do color reduction using also a Median
Cut and Wu Quant algorithms, and has very nice visualization of the
clusters.:
http://rsbweb.nih.gov/ij/plugins/color-inspector.html
Jarek