QuantizerWsmeans

An image quantizer that improves on the speed of a standard K-Means algorithm by implementing several optimizations, including deduping identical pixels and a triangle inequality rule that reduces the number of comparisons needed to identify which cluster a point should be moved to.

Wsmeans stands for Weighted Square Means.

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

Functions

Link copied to clipboard
open fun quantize(inputPixels: Array<Int>, startingClusters: Array<Int>, maxColors: Int): Map<Integer, Integer>
Reduce the number of colors needed to represented the input, minimizing the difference between the original image and the recolored image.