getDescriptor(OperationDescriptor.class, "org.geotools.ColorReduction"));
ParameterBlockJAI pbj = new ParameterBlockJAI("org.geotools.ColorReduction");
// I will tile the image in 4 tiles and force parallelism here
JAI.getDefaultInstance().getTileScheduler().setParallelism(4);
pbj.addSource(
new ImageWorker(image).
setRenderingHint(JAI.KEY_IMAGE_LAYOUT,
new ImageLayout(image).setTileGridXOffset(0).setTileGridYOffset(0).setTileHeight(64).setTileWidth(64)
).tile().getRenderedImage()
);
pbj.setParameter("numColors", 255);
pbj.setParameter("alphaThreshold", 1);
pbj.setParameter("subsampleX", 1);
pbj.setParameter("subsampleY", 1);
indexed = JAI.create("org.geotools.ColorReduction", pbj);
PlanarImage.wrapRenderedImage(indexed).getTiles();
assertTrue(indexed.getColorModel() instanceof IndexColorModel);
// check that we get the same results
assertEquals(indexed.getColorModel(), icm);
icm = (IndexColorModel) indexed.getColorModel();
// make sure we have 4 colors + transparent one
assertEquals(5, icm.getMapSize());
assertEquals(5, icm.getMapSize());
//
// now use the inversion of color
//
assertNotNull((OperationDescriptor)
JAI.getDefaultInstance().getOperationRegistry().
getDescriptor(OperationDescriptor.class, "org.geotools.ColorInversion"));
pbj = new ParameterBlockJAI("org.geotools.ColorInversion");
pbj.addSource(
new ImageWorker(image).
setRenderingHint(JAI.KEY_IMAGE_LAYOUT,
new ImageLayout(image).setTileGridXOffset(0).setTileGridYOffset(0).setTileHeight(64).setTileWidth(64)
).tile().getRenderedImage()
);
pbj.setParameter("quantizationColors", InverseColorMapRasterOp.DEFAULT_QUANTIZATION_COLORS);