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(); }
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,
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; }
@Override public void initialize() throws OperatorException { super.initialize(); band.setSourceImage(ConstantDescriptor.create((float) targetProduct.getSceneRasterWidth(), (float) targetProduct.getSceneRasterHeight(), new Float[]{sampleValue}, null)); }
@Override public void customizeProduct(Product product) { product.removeBand(product.getBand("num_passes")); Band const3 = product.addBand("const3", ProductData.TYPE_INT32); int width = product.getSceneRasterWidth(); int height = product.getSceneRasterHeight(); const3.setSourceImage(ConstantDescriptor.create((float) width, (float) height, new Integer[]{3}, null)); } }
@Override protected void configureTargetProduct(ProductConfigurer productConfigurer) { super.configureTargetProduct(productConfigurer); final Band band = productConfigurer.addBand("const_7", ProductData.TYPE_FLOAT32); band.setSourceImage(ConstantDescriptor.create((float) productConfigurer.getTargetProduct().getSceneRasterWidth(), (float) productConfigurer.getTargetProduct().getSceneRasterHeight(), new Float[]{7.0F}, null)); }
@Override public void initialize() throws OperatorException { Product product = new Product("name", "desc", 1, 1); RenderedOp d = ConstantDescriptor.create( (float) product.getSceneRasterWidth(), (float) product.getSceneRasterHeight(), new Float[]{0.5f}, null); product.addBand("a", ProductData.TYPE_INT32); product.addBand("b", ProductData.TYPE_INT32); product.addBand("c", ProductData.TYPE_INT32); product.addBand("d", ProductData.TYPE_FLOAT32).setSourceImage(d); setTargetProduct(product); }
@Override public void initialize() { int width = sourceProduct.getSceneRasterWidth(); int height = sourceProduct.getSceneRasterHeight(); PlanarImage constImage = ConstantDescriptor.create((float) width, (float) height, new Float[]{66.6f}, null); targetProduct = new Product("name", "desc", width, height); targetProduct.addBand("OperatorBand", ProductData.TYPE_INT8); targetProduct.addBand("ConstantBand", ProductData.TYPE_FLOAT32).setSourceImage(constImage); targetProduct.addBand(new VirtualBand("VirtualBand", ProductData.TYPE_FLOAT32, width, height, "OperatorBand + ConstantBand")); ProductUtils.copyBand(sourceProduct.getBandAt(0).getName(), sourceProduct, targetProduct, true); }
@Test public void testAccumulateWithOnlyNaNDataWithoutMask() throws Exception { final RenderedOp nanImage = ConstantDescriptor.create(11.0f, 1.0f, new Float[]{Float.NaN}, null); SummaryStxOp op = new SummaryStxOp(); op.accumulateData(getPixels(nanImage), null); assertEquals(Double.NaN, op.getMinimum(), 1.0e-6); assertEquals(Double.NaN, op.getMaximum(), 1.0e-6); assertEquals(Double.NaN, op.getMean(), 1.0e-6); assertEquals(Double.NaN, op.getVariance(), 1.0e-6); assertEquals(Double.NaN, op.getStandardDeviation(), 1.0e-6); }
@Test public void testAccumulateWithOnlyNoData() throws Exception { float[] data = new float[11]; RenderedOp maskImage = ConstantDescriptor.create((float) data.length, 1.0f, new Byte[]{0}, null); SummaryStxOp op = new SummaryStxOp(); op.accumulateData(getPixels(new DataBufferFloat(data, data.length)), getPixels(maskImage)); assertEquals(Double.NaN, op.getMinimum(), 1.0e-6); assertEquals(Double.NaN, op.getMaximum(), 1.0e-6); assertEquals(Double.NaN, op.getMean(), 1.0e-6); assertEquals(Double.NaN, op.getVariance(), 1.0e-6); assertEquals(Double.NaN, op.getStandardDeviation(), 1.0e-6); }