public class PopularityQuantizer extends ImageToImageOperation implements RGBIndex, RGBQuantizer
setPaletteSize(int).
RGB24Image,
the output image must be of type Paletted8Image.
PopularityQuantizer quantizer = new PopularityQuantizer(); quantizer.setInputImage(image); quantizer.setPaletteSize(256); quantizer.process(); PixelImage quantizedImage = quantizer.getOutputImage();
ArbitraryPaletteQuantizer| Modifier and Type | Field and Description |
|---|---|
private ArbitraryPaletteQuantizer |
arbQuantizer |
private boolean |
doNotMap |
private Palette |
palette |
private int |
paletteSize |
INDEX_BLUE, INDEX_GREEN, INDEX_RED| Constructor and Description |
|---|
PopularityQuantizer() |
| Modifier and Type | Method and Description |
|---|---|
Palette |
createPalette()
Return a Palette object with the list of colors to be used in the quantization
process.
|
private Palette |
determinePalette() |
int |
getPaletteSize()
Returns the number of colors in the destination image.
|
int |
map(int[] origRgb,
int[] quantizedRgb)
This method maps a triplet of intensity values to its quantized counterpart
and returns the palette index of that quantized color.
|
void |
process()
This method does the actual work of the operation.
|
void |
setMapping(boolean newValue)
Specifies whether this operation will map the image to the
new palette (true) or not (false).
|
void |
setPaletteSize(int newPaletteSize)
Sets the number of colors that this operations is supposed to reduce
the original image to.
|
canInputAndOutputBeEqual, ensureImagesHaveSameResolution, ensureInputImageIsAvailable, ensureOutputImageResolution, getInputImage, getOutputImage, setCanInputAndOutputBeEqual, setInputImage, setOutputImageaddProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgressprivate ArbitraryPaletteQuantizer arbQuantizer
private int paletteSize
private Palette palette
private boolean doNotMap
public Palette createPalette()
RGBQuantizercreatePalette in interface RGBQuantizerprivate Palette determinePalette() throws OperationFailedException
OperationFailedExceptionpublic int getPaletteSize()
setPaletteSize(int)public int map(int[] origRgb,
int[] quantizedRgb)
RGBQuantizermap in interface RGBQuantizerorigRgb - the three samples red, green and blue for which a good match is searched in the palettequantizedRgb - will hold the three samples found to be closest to origRgb after the call to this methodpublic void process()
throws MissingParameterException,
OperationFailedException,
WrongParameterException
Operationprocess in class OperationMissingParameterException - if any mandatory parameter was not given to the operationWrongParameterException - if at least one of the input parameters was
not initialized appropriately (values out of the valid interval, etc.)OperationFailedExceptionpublic void setMapping(boolean newValue)
newValue - map to new image (true) or just search palette (false)public void setPaletteSize(int newPaletteSize)
newPaletteSize - the number of colorsjava.lang.IllegalArgumentException - if the argument is smaller than 1 or larger than 256getPaletteSize()