public byte[] quantizeRasterData(final double newMin, final double newMax, final double gamma, ProgressMonitor pm) throws IOException { final byte[] colorIndexes = new byte[getSceneRasterWidth() * getSceneRasterHeight()]; quantizeRasterData(newMin, newMax, gamma, colorIndexes, 0, 1, pm); return colorIndexes; }
public void quantizeRasterData(double newMin, double newMax, double gamma, byte[] samples, int offset, int stride, ProgressMonitor pm) throws IOException { final ProductData sceneRasterData = getSceneRasterData(); final double rawMin = scaleInverse(newMin); final double rawMax = scaleInverse(newMax); byte[] gammaCurve = null; if (gamma != 0.0 && gamma != 1.0) { gammaCurve = MathUtils.createGammaCurve(gamma, new byte[256]); } if (sceneRasterData != null) { quantizeRasterData(sceneRasterData, rawMin, rawMax, samples, offset, stride, gammaCurve, pm); } else { quantizeRasterDataFromFile(rawMin, rawMax, samples, offset, stride, gammaCurve, pm); } }
/** * Creates a greyscale image from the given <code>{@link RasterDataNode}</code>. * <p/> * <p>The method uses the given raster data node's image information (an instance of <code>{@link * ImageInfo}</code>) to create the image. * * @param rasterDataNode the raster data node, must not be <code>null</code> * @param pm a monitor to inform the user about progress * * @return the color indexed image * * @throws IOException if the given raster data is not loaded and reload causes an I/O error * @see org.esa.beam.framework.datamodel.RasterDataNode#getImageInfo() */ public static BufferedImage createColorIndexedImage(final RasterDataNode rasterDataNode, ProgressMonitor pm) throws IOException { Guardian.assertNotNull("rasterDataNode", rasterDataNode); final int width = rasterDataNode.getSceneRasterWidth(); final int height = rasterDataNode.getSceneRasterHeight(); final ImageInfo imageInfo = rasterDataNode.getImageInfo(ProgressMonitor.NULL); final double newMin = imageInfo.getColorPaletteDef().getMinDisplaySample(); final double newMax = imageInfo.getColorPaletteDef().getMaxDisplaySample(); final byte[] colorIndexes = rasterDataNode.quantizeRasterData(newMin, newMax, 1.0, pm); final IndexColorModel cm = imageInfo.createIndexColorModel(rasterDataNode); final SampleModel sm = cm.createCompatibleSampleModel(width, height); final DataBuffer db = new DataBufferByte(colorIndexes, colorIndexes.length); final WritableRaster wr = WritableRaster.createWritableRaster(sm, db, null); return new BufferedImage(cm, wr, false, null); }
final RasterDataNode raster = rasters[i]; pm.setSubTaskName(taskMessages[i]); raster.quantizeRasterData(imageInfo.getRgbChannelDef().getMinDisplaySample(i), imageInfo.getRgbChannelDef().getMaxDisplaySample(i), imageInfo.getRgbChannelDef().getGamma(i),
raster.quantizeRasterData(minSample, maxSample, 1.0,