Class QuantizerCelebi

java.lang.Object
org.glavo.monetfx.internal.quantize.QuantizerCelebi

public final class QuantizerCelebi extends Object
An image quantizer that improves on the quality of a standard K-Means algorithm by setting the K-Means initial state to the output of a Wu quantizer, instead of random centroids. Improves on speed by several optimizations, as implemented in Wsmeans, or Weighted Square Means, K-Means with those optimizations.

This algorithm was designed by M. Emre Celebi, and was found in their 2011 paper, Improving the Performance of K-Means for Color Quantization. https://arxiv.org/abs/1101.0395

  • Method Details

    • quantize

      public static Map<Integer,Integer> quantize(int[] pixels, int maxColors)
      Reduce the number of colors needed to represented the input, minimizing the difference between the original image and the recolored image.
      Parameters:
      pixels - Colors in ARGB format.
      maxColors - The number of colors to divide the image into. A lower number of colors may be returned.
      Returns:
      Map with keys of colors in ARGB format, and values of number of pixels in the original image that correspond to the color in the quantized image.