/** * Compute the footprint. * * @param geometriesList the List of all the geometries found across the dataset * @param transform * @throws MismatchedDimensionException * @throws TransformException * @throws FactoryException */ private void computeFootprint(List<Polygon> geometriesList, MathTransform transform) throws MismatchedDimensionException, TransformException, FactoryException { // Creating the final multipolygon Polygon[] polArray = new Polygon[geometriesList.size()]; Polygon[] polygons = geometriesList.toArray(polArray); final Geometry innerGeometry = new MultiPolygon(polygons, GF); if (footprintCoordinates == FootprintCoordinates.MODEL_SPACE) { this.footprint = JTS.transform(innerGeometry, transform); } else { this.footprint = innerGeometry; innerGeometry.setSRID(NO_SRID); } // Compute the ROIShape if (!innerGeometry.isEmpty()) { LiteShape2 shape = new LiteShape2(innerGeometry, TRANSLATED_TX, null, false); roiShape = (ROIShape) new ROIShape(shape); } }
new ROIShape( new Rectangle2D.Double( ri.getMinX(),
raster.getWidth(), raster.getHeight()); roi = new ROIShape(bounds);
convertPolygon(roiInput, worldToGridTransform); block.setParameter("roi", new ROIShape(shapePolygon));
convertPolygon(roiInput, worldToGridTransform); outputList.add(new ROIShape(shapePolygon));
protected ROIShape roiCreation() { int roiHeight = imageHeigth / 2; int roiWidth = imageWidth / 2; Rectangle roiBound = new Rectangle(0, 0, roiWidth, roiHeight); ROIShape roi = new ROIShape(roiBound); return roi; }
protected ROIShape roiCreation() { int roiHeight = imageHeigth / 2; int roiWidth = imageWidth / 2; Rectangle roiBound = new Rectangle(0, 0, roiWidth, roiHeight); ROIShape roi = new ROIShape(roiBound); return roi; }
protected ROIShape roiCreation() { int roiHeight = imageHeigth / 2; int roiWidth = imageWidth / 2; Rectangle roiBound = new Rectangle(0, 0, roiWidth, roiHeight); ROIShape roi = new ROIShape(roiBound); return roi; }
protected ROIShape roiCreation() { int roiHeight = DEFAULT_HEIGHT *3/ 4; int roiWidth = DEFAULT_WIDTH *3/ 4; Rectangle roiBound = new Rectangle(0, 0, roiWidth, roiHeight); ROIShape roi = new ROIShape(roiBound); return roi; }
rois[i] = newRois[i]; } else { rois[i] = new ROIShape(PlanarImage.wrapRenderedImage(rasters[i]).getBounds());
/** * Turns the roi geometry in a ROIShape with the same geometry * @param g * @return */ ROIShape getEquivalentROIShape(ROIGeometry g) { // get the roi geometry as shape, this generate a JTS wrapper final Shape shape = g.getAsShape(); return new ROIShape(shape); }
@BeforeClass public static void initialSetup() { // Setting of an input parameter to be always false, avoiding the image to be totally filled by values IMAGE_FILLER = false; // Byte Range goes from 0 to 255 noDataB = (byte) 156; noDataUS = 100; noDataS = -100; noDataI = -100; // Images initialization // Test images creation testImageByte = createTestImage(DataBuffer.TYPE_BYTE, DEFAULT_WIDTH, DEFAULT_HEIGHT, noDataB, false); // ROI creation Rectangle roiBounds = new Rectangle(0, 0, DEFAULT_WIDTH / 4, DEFAULT_HEIGHT / 4); roi = new ROIShape(roiBounds); // Destination No Data destinationNoDataValue = 255; }
@BeforeClass public static void initialSetup() { images = new RenderedImage[6]; IMAGE_FILLER = true; images[0] = createTestImage(DataBuffer.TYPE_BYTE, WIDTH, WIDTH, (byte) 0, false); images[1] = createTestImage(DataBuffer.TYPE_USHORT, WIDTH, WIDTH, (short) 0, false); images[2] = createTestImage(DataBuffer.TYPE_SHORT, WIDTH, WIDTH, (short) 0, false); images[3] = createTestImage(DataBuffer.TYPE_INT, WIDTH, WIDTH, 0, false); images[4] = createTestImage(DataBuffer.TYPE_FLOAT, WIDTH, WIDTH, 0f, false); images[5] = createTestImage(DataBuffer.TYPE_DOUBLE, WIDTH, WIDTH, 0d, false); IMAGE_FILLER = false; roi = new ROIShape(new Rectangle(2, 2, 3, 3)); defaultV = new Double(13); }
@BeforeClass public static void initialSetup() { images = new TiledImage[DEFAULT_IMG_NUM]; images[0] = createImage(DataBuffer.TYPE_BYTE, INPUT); images[1] = createImage(DataBuffer.TYPE_USHORT, INPUT); images[2] = createImage(DataBuffer.TYPE_SHORT, INPUT); images[3] = createImage(DataBuffer.TYPE_INT, INPUT); images[4] = createImage(DataBuffer.TYPE_FLOAT, INPUT); images[5] = createImage(DataBuffer.TYPE_DOUBLE, INPUT); imageFinal = createImage(DataBuffer.TYPE_INT, OUTPUT); rois = new ArrayList<ROI>(1); rois.add(new ROIShape(new Rectangle(10, 10, 10, 10))); leftPad = 10; rightPad = 10; topPad = 10; bottomPad = 10; type = DataBuffer.TYPE_INT; extender = BufferDescriptor.DEFAULT_EXTENDER; noDataValue = 0.0d; pixelArea = 1.0d; }
/** * Build a 4x4 image with pixels having value as the sum of their coordinates, attaches * a ROI covering the 4 central pixels, and scales up by a factor of 2 with the given interpolation * @param dataType * @return */ protected RenderedImage buildImageWithROI(int dataType, Interpolation interpolation, boolean useROIAccessor, Range noData) { int width = 4; int height = 4; SampleModel sm = new ComponentSampleModel(dataType, width, height, 1, width, new int[] {0}); TiledImage source = new TiledImage(0, 0, width, height, 0, 0, sm, PlanarImage.createColorModel(sm)); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { source.setSample(x, y, 0, x + y); } } // build a ROI covering the center of the image and associate ROI roi = new ROIShape(new Rectangle(1, 1, 2, 2)); RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,BorderExtender.createInstance(BorderExtender.BORDER_COPY)); hints.put(JAI.KEY_IMAGE_LAYOUT, new ImageLayout(0, 0, width * 2, height * 2, 0, 0, width * 2, height * 2, null, null)); return ScaleDescriptor.create(source, 2f, 2f, 0f, 0f, interpolation, roi, useROIAccessor, noData, new double[] {0}, hints); }
public void testTranslation(boolean useROIAccessor, int dataType, float xScale, float yScale, float xTrans, float yTrans, byte imageValue, Interpolation interpolation) { RenderedImage testIMG = createTestImage(dataType, DEFAULT_WIDTH, DEFAULT_HEIGHT, imageValue, false); PlanarImage testImgWithROI = PlanarImage.wrapRenderedImage(testIMG); testImgWithROI.setProperty("roi", new ROIShape(new Rectangle(0, 0, DEFAULT_WIDTH / 2, DEFAULT_HEIGHT / 2))); // Scaled images RenderedOp scaleImgNear = ScaleDescriptor.create(testImgWithROI, xScale, yScale, xTrans, yTrans, interpolation, null, useROIAccessor, null, null, null); scaleImgNear.getTiles(); // verify the translate int optimization, and that assertThat(scaleImgNear.getRendering(), instanceOf(TranslateIntOpImage.class)); Object roi = scaleImgNear.getProperty("roi"); assertThat(roi, instanceOf(ROI.class)); assertThat(((ROI) roi).getAsImage(), instanceOf(TranslateIntOpImage.class)); double actualX=scaleImgNear.getMinX(); double actualY=scaleImgNear.getMinY(); double expectedX=testIMG.getMinX()+ xTrans; double expectedY=testIMG.getMinY()+ yTrans; double tolerance = 0.1f; assertEquals(expectedX, actualX,tolerance); assertEquals(expectedY, actualY,tolerance); //Final Image disposal if(scaleImgNear instanceof RenderedOp){ ((RenderedOp)scaleImgNear).dispose(); } }