Class MedianCutQuantizer
- java.lang.Object
-
- net.sourceforge.plantuml.quantization.MedianCutQuantizer
-
- All Implemented Interfaces:
ColorQuantizer
public final class MedianCutQuantizer extends Object implements ColorQuantizer
Implements median cut quantization.The algorithm works as follows:
- Begin with one cluster containing all the original colors.
- Find the cluster containing the greatest spread along a single color component (red, green or blue).
- Find the median of that color component among colors in the cluster.
- Split the cluster into two halves, using that median as a threshold.
- Repeat this process until the desired number of clusters is reached.
-
-
Field Summary
Fields Modifier and Type Field Description static MedianCutQuantizerINSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<QColor>quantize(Multiset<QColor> originalColors, int maxColorCount)Quantize the given set of colors, returning a set no larger thanmaxColors.
-
-
-
Field Detail
-
INSTANCE
public static final MedianCutQuantizer INSTANCE
-
-
Method Detail
-
quantize
public Set<QColor> quantize(Multiset<QColor> originalColors, int maxColorCount)
Description copied from interface:ColorQuantizerQuantize the given set of colors, returning a set no larger thanmaxColors.The intent is to pick a set of colors which are representative of the original color set, but no specific guarantees are made.
- Specified by:
quantizein interfaceColorQuantizer- Parameters:
originalColors- the colors in the original imagemaxColorCount- the maximum number of colors to allow- Returns:
- a quantized collection of colors no larger than
maxColors
-
-