private void mapImage()
{
RGB24Image in = (RGB24Image)getInputImage();
Palette palette = createPalette();
Paletted8Image out = new MemoryPaletted8Image(in.getWidth(), in.getHeight(), palette);
int[] origRgb = new int[3];
int[] quantizedRgb = new int[3];
for (int y = 0; y < in.getHeight(); y++)
{
for (int x = 0; x < in.getWidth(); x++)
{
origRgb[INDEX_RED] = in.getSample(INDEX_RED, x, y);
origRgb[INDEX_GREEN] = in.getSample(INDEX_GREEN, x, y);
origRgb[INDEX_BLUE] = in.getSample(INDEX_BLUE, x, y);
int index = map(origRgb, quantizedRgb);
out.putSample(0, x, y, index);
}
}
setOutputImage(out);
}