lower[targetGG.gridDimensionY] = targetImage.getMinY(); upper[targetGG.gridDimensionX] = targetImage.getMaxX(); upper[targetGG.gridDimensionY] = targetImage.getMaxY();
logger.log(Level.parse(S2Config.LOG_SCENE), String.format("mosaicOp created for level %d at (%d,%d) with size (%d, %d)%n", level, mosaicOp.getMinX(), mosaicOp.getMinY(), mosaicOp.getWidth(), mosaicOp.getHeight()));
logger.log(Level.parse(S2Config.LOG_SCENE), String.format("mosaicOp created for level %d at (%d,%d) with size (%d, %d)%n", level, mosaicOp.getMinX(), mosaicOp.getMinY(), mosaicOp.getWidth(), mosaicOp.getHeight()));
final int minY = tempLatImg.getMinY(); int numTiePoints = tpGridWidth * tpGridHeight; final boolean containsAngles = true;
public void testTranslation(boolean useROIAccessor, int dataType, double xScale, double yScale, double xTrans, double 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 = Scale2Descriptor.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(); } }
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(); } }
private void assertCopy(RenderedImage src, RenderedOp op, int dataType) { // check it's a copy with the expected values assertEquals(src.getMinX(), op.getMinX()); assertEquals(src.getWidth(), op.getWidth()); assertEquals(src.getMinY(), op.getMinY()); assertEquals(src.getHeight(), op.getHeight()); assertEquals(dataType, op.getSampleModel().getDataType()); RandomIter srcIter = RandomIterFactory.create(src, null); RandomIter opIter = RandomIterFactory.create(op, null); for(int y = src.getMinY(); y < src.getMinY() + src.getHeight(); y++) { for(int x = src.getMinX(); x < src.getMinX() + src.getWidth(); x++) { double expected = srcIter.getSampleDouble(x, y, 0); double actual = opIter.getSampleDouble(x, y, 0); assertEquals(expected, actual, 0d); } } }
@Test public void testThatImageMinXYAreImportant() throws Exception { int minX = 4; int minY = 3; final RenderedOp src = ConstantDescriptor.create(16F, 16F, new Short[]{(short) 33}, null); final RenderedOp dst = CropDescriptor.create(src, (float) minX, (float) minY, 8F, 8F, null); assertEquals(minX, dst.getMinX()); assertEquals(minY, dst.getMinY()); // Test that we have to use the min X and Y try { dst.getData(new Rectangle(0, 0, 1, 1)); fail("IllegalArgumentException thrown by JAI expected"); } catch (IllegalArgumentException e) { // ok } final Raster data = dst.getData(new Rectangle(minX, minY, 1, 1)); final short[] outData = new short[1]; // Test that we have to use the min X and Y try { data.getDataElements(0, 0, outData); fail("ArrayIndexOutOfBoundsException thrown by AWT expected"); } catch (ArrayIndexOutOfBoundsException e) { // ok } data.getDataElements(minX, minY, outData); assertEquals(33, outData[0]); // In many cases, we use the tile rectangles in order to retrieve pixel data // So make sure it also considers the min X and Y assertEquals(new Rectangle(minX, minY, 8, 8), dst.getTileRect(0, 0)); }
@Test public void testSum() { RenderedImage src1 = buildTestImage(10, 10); RenderedImage src2 = buildTestImage(10, 10); RenderedOp op = JiffleDescriptor.create(new RenderedImage[] {src1, src2}, new String[] {"a", "b"}, "res", "res = a + b;", null, DataBuffer.TYPE_INT, null, null, null); // check same size and expected assertEquals(src1.getMinX(), op.getMinX()); assertEquals(src1.getWidth(), op.getWidth()); assertEquals(src1.getMinY(), op.getMinY()); assertEquals(src1.getHeight(), op.getHeight()); assertEquals(DataBuffer.TYPE_INT, op.getSampleModel().getDataType()); RandomIter srcIter = RandomIterFactory.create(src1, null); RandomIter opIter = RandomIterFactory.create(op, null); for(int y = src1.getMinY(); y < src1.getMinY() + src1.getHeight(); y++) { for(int x = src1.getMinX(); x < src1.getMinX() + src1.getWidth(); x++) { double expected = srcIter.getSampleDouble(x, y, 0) * 2; double actual = opIter.getSampleDouble(x, y, 0); assertEquals(expected, actual, 0d); } } }
testIMG.getMinY() + interpNear.getTopPadding(), testIMG.getWidth() - interpNear.getWidth() + 1, testIMG.getHeight() - interpNear.getHeight() + 1);
assertEquals(0, image.getMinY()); assertEquals(10, image.getTileWidth()); assertEquals(10, image.getTileHeight());
assertEquals(finalimage.getMinY(), image.getMinY()); assertEquals(finalimage.getWidth(), image.getWidth()); assertEquals(finalimage.getHeight(), image.getHeight());
assertEquals(destinationIMG.getMinY(), outputRect.y); assertEquals(destinationIMG.getHeight(), outputRect.width); assertEquals(destinationIMG.getWidth(), outputRect.height);
assertEquals(shaded.getHeight(), src.getHeight()); assertEquals(shaded.getMinX(), src.getMinX()); assertEquals(shaded.getMinY(), src.getMinY()); assertEquals(minTileX, src.getMinTileX()); assertEquals(minTileY, src.getMinTileY());
Rectangle roiBounds = new Rectangle(image.getMinX() + 5, image.getMinY() + 5, image.getWidth() / 4, image.getHeight() / 4); ROI roi = new ROIShape(roiBounds);
assertEquals(dest.getHeight(), src.getHeight()); assertEquals(dest.getMinX(), src.getMinX()); assertEquals(dest.getMinY(), src.getMinY()); assertEquals(minTileX, src.getMinTileX()); assertEquals(minTileY, src.getMinTileY());
assertEquals(clamped.getHeight(), src.getHeight()); assertEquals(clamped.getMinX(), src.getMinX()); assertEquals(clamped.getMinY(), src.getMinY()); assertEquals(minTileX, src.getMinTileX()); assertEquals(minTileY, src.getMinTileY());