/** Apply a Raster classification on the underlying image. */ public ImageWorker classify(ColorMapTransform domain1D, Integer bandIndex) { ParameterBlock pb = new ParameterBlock(); pb.setSource(image, 0); // The source image. pb.set(domain1D, 0); pb.set(bandIndex, 1); pb.set(roi, 2); pb.set(nodata, 3); if (isNoDataNeeded()) { if (domain1D.hasGaps()) { // We must set the new NoData value setNoData( RangeFactory.create( domain1D.getDefaultValue(), domain1D.getDefaultValue())); } } image = JAI.create("RasterClassifier", pb, getRenderingHints()); return this; }
/** * Prepare the {@link ImageLayout} for the final image by building the {@link ColorModel} from the input * * @param image the image to classify. * @param layout a proposed layout. * @param lic the pieces we are asked to use. * @return a layout suitable for the image that we'll create after this */ private static <T extends ColorMapTransformElement> ImageLayout prepareLayout( RenderedImage image, ImageLayout layout, ColorMapTransform<T> lic) { // // // // Get the final color model from the pieces and from that one // create the sample model // // /// final ColorModel finalColorModel = lic.getColorModel(); // create a good sample model for the output raster final SampleModel finalSampleModel = lic .getSampleModel(image.getWidth(), image.getHeight()); if (layout == null) layout = new ImageLayout(); layout.setColorModel(finalColorModel); layout.setSampleModel(finalSampleModel); return layout; } }
/** * Prepare the {@link ImageLayout} for the final image by building the {@link ColorModel} from the input * * @param image the image to classify. * @param layout a proposed layout. * @param lic the pieces we are asked to use. * @return a layout suitable for the image that we'll create after this */ private static <T extends ColorMapTransformElement> ImageLayout prepareLayout( RenderedImage image, ImageLayout layout, ColorMapTransform<T> lic) { // // // // Get the final color model from the pieces and from that one // create the sample model // // /// final ColorModel finalColorModel = lic.getColorModel(); // create a good sample model for the output raster final SampleModel finalSampleModel = lic .getSampleModel(image.getWidth(), image.getHeight()); if (layout == null) layout = new ImageLayout(); layout.setColorModel(finalColorModel); layout.setSampleModel(finalSampleModel); return layout; } }