quantize method

  1. @override
QuantizerResult quantize(
  1. List<int> pixels,
  2. int maxColors, {
  3. bool returnInputPixelToClusterPixel = false,
})
override

Reduce the number of colors needed to represented the input, minimizing the difference between the original image and the recolored image.

Returns a 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.

Implementation

@override
QuantizerResult quantize(
  List<int> pixels,
  int maxColors, {
  bool returnInputPixelToClusterPixel = false,
}) {
  final wu = QuantizerWu();
  final wuResult = wu.quantize(pixels, maxColors);
  final wsmeansResult = const QuantizerWsmeans().quantize(
    pixels,
    maxColors,
    startingClusters: wuResult.colorToCount.keys.toList(),
    pointProvider: const PointProviderLab(),
    returnInputPixelToClusterPixel: returnInputPixelToClusterPixel,
  );
  return wsmeansResult;
}