- All Known Implementing Classes:
KMeansClusteringQuantizer
,MedianCutQuantizer
,OctreeQuantizer
public interface ColorQuantizer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault int
findColorIndex
(int p, float[][] colormap) Finds the color table index of the color that is "closest" to the supplied RGB color (minimum Euclidean distance in color space).static byte
floatToUnsignedByte
(float x) default int
Returns the number of quantized colors.float[][]
Retrieves the color map produced by this color quantizer.static IndexColorModel
makeIndexColorModel
(float[][] colormap) default int
quantize
(int rgb) Performs color quantization on the given single ARGB-encoded color value and returns the associated quantized color.default int[]
quantize
(int[] origPixels) Performs color quantization on the given array of ARGB-encoded color values and returns a new sequence of quantized colors.default ByteProcessor
Performs color quantization on the given full-color RGB image and creates an indexed color image.
-
Field Details
-
MAX_RGB
- See Also:
-
-
Method Details
-
getColorMap
float[][] getColorMap()Retrieves the color map produced by this color quantizer. The returned array is in the format float[idx][rgb], where rgb = 0 (red), 1 (green), 2 (blue) and 0 ≤ idx < nColors.- Returns:
- The table of reference (quantization) colors.
-
getColorCount
Returns the number of quantized colors.- Returns:
- the number of quantized colors
-
quantize
Performs color quantization on the given full-color RGB image and creates an indexed color image.- Parameters:
cp
- The original full-color RGB image.- Returns:
- The quantized (indexed color) image.
-
makeIndexColorModel
-
floatToUnsignedByte
-
quantize
Performs color quantization on the given array of ARGB-encoded color values and returns a new sequence of quantized colors.- Parameters:
origPixels
- The original ARGB-encoded color values.- Returns:
- The quantized ARGB-encoded color values.
-
quantize
Performs color quantization on the given single ARGB-encoded color value and returns the associated quantized color.- Parameters:
rgb
- The original ARGB-encoded color value.- Returns:
- The quantized ARGB-encoded color value.
-
findColorIndex
Finds the color table index of the color that is "closest" to the supplied RGB color (minimum Euclidean distance in color space). This method may be overridden by inheriting classes, for example, to use quick indexing in the octree method.- Parameters:
p
- Original color, encoded as an ARGB integer.colormap
- a color map (float)- Returns:
- The associated color table index.
-