Interface ColorQuantizer

All Known Implementing Classes:
KMeansClusteringQuantizer, MedianCutQuantizer, OctreeQuantizer

public interface ColorQuantizer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default 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
     
    default int
    Returns the number of quantized colors.
    float[][]
    Retrieves the color map produced by this color quantizer.
    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.
    Performs color quantization on the given full-color RGB image and creates an indexed color image.
  • Field Details

  • 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

      default int 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

      static IndexColorModel makeIndexColorModel(float[][] colormap)
    • floatToUnsignedByte

      static byte floatToUnsignedByte(float x)
    • quantize

      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.
      Parameters:
      origPixels - The original ARGB-encoded color values.
      Returns:
      The quantized ARGB-encoded color values.
    • quantize

      default int quantize(int rgb)
      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

      default 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). 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.