Number[] bandValues = new Number[numBands]; // all zeroes Arrays.fill(bandValues, Double.valueOf(0)); ConstantDescriptor.create( width, height,
/** * Adds an extra channel to the image, with a value of 255 (not public yet because it won't work * with all image types) * * @return */ private ImageWorker addAlphaChannel() { final ImageLayout tempLayout = new ImageLayout(image); tempLayout .unsetValid(ImageLayout.COLOR_MODEL_MASK) .unsetValid(ImageLayout.SAMPLE_MODEL_MASK); RenderedImage alpha = ConstantDescriptor.create( Float.valueOf(image.getWidth()), Float.valueOf(image.getHeight()), new Byte[] {Byte.valueOf((byte) 255)}, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, tempLayout)); addBand(alpha, false, true, null); return this; }
/** * Post processes a blank image response, eventually making it transparent * * @param finalImage * @return */ public RenderedImage postProcessBlankResponse(RenderedImage finalImage, RenderingHints hints) { // prepare a ROI made of only zeroes ImageLayout layout = new ImageLayout( finalImage.getMinX(), finalImage.getMinY(), finalImage.getWidth(), finalImage.getHeight()); RenderedOp roi = ConstantDescriptor.create( (float) finalImage.getWidth(), (float) finalImage.getHeight(), new Byte[] {0}, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout)); ImageWorker iw = new ImageWorker(finalImage); iw.setROI(new ROI(roi)); return iw.getRenderedImage(); } }
return ConstantDescriptor.create( Float.valueOf(rasterBounds.width), Float.valueOf(rasterBounds.height),
ConstantDescriptor.create( new Float(w), new Float(h), new Byte[] {(byte) 255}, hints);
ConstantDescriptor.create( new Float(w), new Float(h), new Byte[] {(byte) 255}, hints);
public static PlanarImage createColoredMaskImage(Color color, RenderedImage alphaImage, RenderingHints hints) { RenderedOp colorImage = ConstantDescriptor.create( (float) alphaImage.getWidth(), (float) alphaImage.getHeight(), new Byte[]{ (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), }, hints); return BandMergeDescriptor.create(colorImage, alphaImage, hints); }
public static RenderedImage createConstImage(int width, int height, Integer n) { return ConstantDescriptor.create((float) width, (float) height, new Integer[]{n}, null).getAsBufferedImage(); }
/** * Creates a bkg image using the supplied parameters. * * @param width the width of the timage to create * @param height the height of the image to create * @param bgColor the background color of the image to create * @param renderingHints the hints to apply * @return a {@link RenderedImage} with constant values as fill */ private static final RenderedImage createBkgImage( float width, float height, Color bgColor, RenderingHints renderingHints) { // prepare bands for constant image if needed final Number[] bands = new Byte[] { (byte) bgColor.getRed(), (byte) bgColor.getGreen(), (byte) bgColor.getBlue(), (byte) bgColor.getAlpha() }; return ConstantDescriptor.create(width, height, bands, renderingHints); }
public static BufferedImage createConstImage2(int width, int height, Integer n) { return ConstantDescriptor.create((float) width, (float) height, new Integer[]{n}, null).getAsBufferedImage(); }
image.getHeight()); RenderedOp alphaBand = ConstantDescriptor.create( (float) image.getWidth(), (float) image.getHeight(),
ConstantDescriptor.create( (float) rasterBounds.width, (float) rasterBounds.height,
@Before public void setup() { sourceImages = new RenderedImage[]{ ConstantDescriptor.create(10.0f, 10.0f, new Float[]{2.0f}, null), ConstantDescriptor.create(10.0f, 10.0f, new Float[]{3.0f}, null), ConstantDescriptor.create(10.0f, 10.0f, new Float[]{5.0f}, null), ConstantDescriptor.create(10.0f, 10.0f, new Float[]{7.0f}, null) }; alphaImages = new PlanarImage[]{ PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{1.0f}, null)), PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{2.0f}, null)), PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{3.0f}, null)), PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{4.0f}, null)) }; }
private RenderedImage addAlphaChannel(RenderedImage image) { final ImageLayout tempLayout = new ImageLayout(image); tempLayout .unsetValid(ImageLayout.COLOR_MODEL_MASK) .unsetValid(ImageLayout.SAMPLE_MODEL_MASK); RenderedImage alpha = ConstantDescriptor.create( Float.valueOf(image.getWidth()), Float.valueOf(image.getHeight()), new Byte[] {Byte.valueOf((byte) 255)}, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, tempLayout)); // Using an ImageWorker ImageWorker iw = new ImageWorker(image); // Adding Alpha band iw.addBand(alpha, false, true, null); return iw.getRenderedImage(); }
PlanarImage createValidMaskImage(Product product) { if (expression != null && product.isCompatibleBandArithmeticExpression(expression)) { return VirtualBandOpImage.create(expression, ProductData.TYPE_UINT8, 0, product, ResolutionLevel.MAXRES); } else { return ConstantDescriptor.create((float) product.getSceneRasterWidth(), (float) product.getSceneRasterHeight(), new Byte[]{-1}, null); } }
private static Band createBand(float fillValue) { final Band band = new Band("b1", ProductData.TYPE_FLOAT32, WIDTH, HEIGHT); band.setSourceImage(ConstantDescriptor.create((float) WIDTH, (float) HEIGHT, new Float[]{fillValue}, null)); return band; }
break; return ConstantDescriptor.create((float) source.getWidth(), (float) source.getHeight(), alphaValues,
opImage = ConstantDescriptor.create((float) layout.tileWidth, (float) layout.tileHeight, new Number[]{0}, null);
public static Product createProduct3() { int size = 10 * 1024; Product product = new Product("Test_Product_3", "Test_Type_3", size, size); product.setPreferredTileSize(512, 512); Band band1 = new Band("Big_Band_1", ProductData.TYPE_FLOAT64, product.getSceneRasterWidth(), product.getSceneRasterHeight()); Band band2 = new Band("Big_Band_2", ProductData.TYPE_FLOAT64, product.getSceneRasterWidth(), product.getSceneRasterHeight()); Band band3 = new Band("Big_Band_3", ProductData.TYPE_FLOAT64, product.getSceneRasterWidth(), product.getSceneRasterHeight()); Band band4 = new Band("Big_Band_4", ProductData.TYPE_FLOAT64, product.getSceneRasterWidth(), product.getSceneRasterHeight()); Band band5 = new Band("Big_Band_5", ProductData.TYPE_FLOAT64, product.getSceneRasterWidth(), product.getSceneRasterHeight()); band1.setSourceImage(ConstantDescriptor.create(1f * size, 1F * size, new Double[]{1.0}, null)); band2.setSourceImage(ConstantDescriptor.create(1f * size, 1F * size, new Double[]{2.0}, null)); band3.setSourceImage(ConstantDescriptor.create(1f * size, 1F * size, new Double[]{3.0}, null)); band4.setSourceImage(ConstantDescriptor.create(1f * size, 1F * size, new Double[]{4.0}, null)); band5.setSourceImage(ConstantDescriptor.create(1f * size, 1F * size, new Double[]{5.0}, null)); product.addBand(band1); product.addBand(band2); product.addBand(band3); product.addBand(band4); product.addBand(band5); product.setModified(true); double sx = 30.0 / product.getSceneRasterWidth(); AffineTransform at = new AffineTransform(); at.translate(100, 0.0); at.rotate(0.1, 15.0, 15.0); at.scale(sx, sx); product.setSceneGeoCoding(new ATGeoCoding(at)); return product; }
protected PlanarImage createConstantTileImage(String tileId, int level) { S2IndexBandInformation indexBandInformation = (S2IndexBandInformation) tileBandInfo.getBandInformation(); IndexCoding indexCoding = indexBandInformation.getIndexCoding(); Integer indexValue = indexCoding.getIndexValue(S2L1BGranuleDirFilename.create(tileId).getTileID()); short indexValueShort = indexValue.shortValue(); Rectangle tileRectangleL0 = new Rectangle(); tileRectangleL0.height = tileBandInfo.getImageLayout().height; tileRectangleL0.width = tileBandInfo.getImageLayout().width; sceneDescription.getTileRectangle(sceneDescription.getTileIndex(tileId)); Rectangle tileRectangle = DefaultMultiLevelSource.getLevelImageBounds(tileRectangleL0, getModel().getScale(level)); PlanarImage planarImage = ConstantDescriptor.create((float) tileRectangle.width, (float) tileRectangle.height, new Short[]{indexValueShort}, null); return planarImage; }