/** * Computes the interpolated sample for the pixel located at (x,y). <p/> * <p/> * If the pixel co-odinates given by (x,y) are not covered by this tie-point grid, the method extrapolates. * * @param x The X co-ordinate of the pixel location, given in the pixel co-ordinates of the data product to which * this tie-pint grid belongs to. * @param y The Y co-ordinate of the pixel location, given in the pixel co-ordinates of the data product to which * this tie-pint grid belongs to. * * @throws ArrayIndexOutOfBoundsException if the co-ordinates are not in bounds */ @Override public float getPixelFloat(int x, int y) { return getPixelFloat(x + 0.5f, y + 0.5f); }
/** * Gets the interpolated sample for the pixel located at (x,y) as a double value. <p/> * <p/> * If the pixel co-ordinates given by (x,y) are not covered by this tie-point grid, the method extrapolates. * * @param x The X co-ordinate of the pixel location, given in the pixel co-ordinates of the data product to which * this tie-pint grid belongs to. * @param y The Y co-ordinate of the pixel location, given in the pixel co-ordinates of the data product to which * this tie-pint grid belongs to. * * @throws ArrayIndexOutOfBoundsException if the co-ordinates are not in bounds */ @Override public double getPixelDouble(int x, int y) { return getPixelFloat(x, y); }
/** * Gets the interpolated sample for the pixel located at (x,y) as an integer value. <p/> * <p/> * If the pixel co-odinates given by (x,y) are not covered by this tie-point grid, the method extrapolates. * * @param x The X co-ordinate of the pixel location * @param y The Y co-ordinate of the pixel location * * @throws ArrayIndexOutOfBoundsException if the co-ordinates are not in bounds */ @Override public int getPixelInt(int x, int y) { return Math.round(getPixelFloat(x, y)); }
public final AngularDirection getViewDir(PixelPos pixelPos, AngularDirection vd) { if (canGetViewDir()) { if (vd == null) { vd = new AngularDirection(); } vd.azimuth = _vaGrid.getPixelFloat(pixelPos.x, pixelPos.y); vd.zenith = _vzGrid.getPixelFloat(pixelPos.x, pixelPos.y); } return vd; }
public final AngularDirection getSunDir(PixelPos pixelPos, AngularDirection sd) { if (canGetSunDir()) { if (sd == null) { sd = new AngularDirection(); } sd.azimuth = _saGrid.getPixelFloat(pixelPos.x, pixelPos.y); sd.zenith = _szGrid.getPixelFloat(pixelPos.x, pixelPos.y); } return sd; }
private static float[] createBandData(TiePointGrid grid) { float[] floats = new float[PW * PH]; for (int y = 0; y < PH; y++) { for (int x = 0; x < PW; x++) { floats[y * PW + x] = grid.getPixelFloat(x, y); } } return floats; }
private static float[] createBandData(TiePointGrid grid) { float[] floats = new float[PW * PH]; for (int y = 0; y < PH; y++) { for (int x = 0; x < PW; x++) { floats[y * PW + x] = grid.getPixelFloat(x, y); } } return floats; }
public float getElevation(PixelPos pixelPos) { return canGetElevation() ? _elGrid.getPixelFloat(pixelPos.x, pixelPos.y) : 0.0f; }
/** * Returns the latitude and longitude value for a given pixel co-ordinate. * * @param pixelPos the pixel's co-ordinates given as x,y * @param geoPos an instance of <code>GeoPos</code> to be used as retun value. If this parameter is * <code>null</code>, the method creates a new instance which it then returns. * * @return the geographical position as lat/lon. */ @Override public GeoPos getGeoPos(final PixelPos pixelPos, GeoPos geoPos) { if (geoPos == null) { geoPos = new GeoPos(); } if (pixelPos.x < 0 || pixelPos.x > latGrid.getSceneRasterWidth() || pixelPos.y < 0 || pixelPos.y > latGrid.getSceneRasterHeight()) { geoPos.setInvalid(); } else { geoPos.lat = latGrid.getPixelFloat(pixelPos.x, pixelPos.y); geoPos.lon = lonGrid.getPixelFloat(pixelPos.x, pixelPos.y); } return geoPos; }
public void testExtrapolation() { TiePointGrid grid = new TiePointGrid("x", 3, 5, 0.5f, 0.5f, 4, 2, _tiePoints); assertEquals(-0.75F, grid.getPixelFloat(-1, -1), _eps); assertEquals(+0.50F, grid.getPixelFloat(4, -1), _eps); assertEquals(+1.75F, grid.getPixelFloat(9, -1), _eps); assertEquals(+1.75F, grid.getPixelFloat(-1, 4), _eps); assertEquals(+3.00F, grid.getPixelFloat(4, 4), _eps); assertEquals(+4.25F, grid.getPixelFloat(9, 4), _eps); assertEquals(+4.25F, grid.getPixelFloat(-1, 9), _eps); assertEquals(+5.50F, grid.getPixelFloat(4, 9), _eps); assertEquals(+6.75F, grid.getPixelFloat(9, 9), _eps); }
initDiscont(); final float sinAngle = sinGrid.getPixelFloat(x, y); final float cosAngle = cosGrid.getPixelFloat(x, y); final float v = (float) (MathUtils.RTOD * Math.atan2(sinAngle, cosAngle)); if (discontinuity == DISCONT_AT_360 && v < 0.0) {
assertEquals(2, tiePointGrid.getPixelFloat(0.5f, 1.5f), 1e-5f); assertEquals(4, tiePointGrid.getPixelFloat(3.5f, 1.5f), 1e-5f); assertEquals(6, tiePointGrid.getPixelFloat(6.5f, 1.5f), 1e-5f); assertEquals(12, tiePointGrid.getPixelFloat(0.5f, 6.5f), 1e-5f); assertEquals(10, tiePointGrid.getPixelFloat(3.5f, 6.5f), 1e-5f); assertEquals(8, tiePointGrid.getPixelFloat(6.5f, 6.5f), 1e-5f); assertEquals(14, tiePointGrid.getPixelFloat(0.5f, 11.5f), 1e-5f); assertEquals(16, tiePointGrid.getPixelFloat(3.5f, 11.5f), 1e-5f); assertEquals(18, tiePointGrid.getPixelFloat(6.5f, 11.5f), 1e-5f); assertEquals(1, tiePointGrid.getPixelFloat(-1f, 1.5f), 1e-5f); assertEquals(3, tiePointGrid.getPixelFloat(2f, 1.5f), 1e-5f); assertEquals(5, tiePointGrid.getPixelFloat(5f, 1.5f), 1e-5f); assertEquals(7, tiePointGrid.getPixelFloat(8f, 1.5f), 1e-5f); assertEquals(-3, tiePointGrid.getPixelFloat(0.5f, -1f), 1e-5f); assertEquals(7, tiePointGrid.getPixelFloat(0.5f, 4f), 1e-5f); assertEquals(13, tiePointGrid.getPixelFloat(0.5f, 9f), 1e-5f); assertEquals(15, tiePointGrid.getPixelFloat(0.5f, 14f), 1e-5f); assertEquals(7, tiePointGrid.getPixelFloat(2f, 4f), 1e-5f); assertEquals(7, tiePointGrid.getPixelFloat(5f, 4f), 1e-5f); assertEquals(13, tiePointGrid.getPixelFloat(2f, 9f), 1e-5f); assertEquals(13, tiePointGrid.getPixelFloat(5f, 9f), 1e-5f); assertEquals(-5, tiePointGrid.getPixelFloat(-1f, -1f), 1e-5f); assertEquals(7, tiePointGrid.getPixelFloat(8f, -1f), 1e-5f); assertEquals(13, tiePointGrid.getPixelFloat(-1f, 14f), 1e-5f); assertEquals(25, tiePointGrid.getPixelFloat(8f, 14f), 1e-5f);
public void testInterpolation() { TiePointGrid grid = new TiePointGrid("x", 3, 5, 0.5f, 0.5f, 4, 2, _tiePoints); float[][] interpolated = new float[][]{ {0.0F, 0.5F, 1.0F, 1.5F, 2.0F}, {0.5F, 1.0F, 1.5F, 2.0F, 2.5F}, {1.0F, 1.5F, 2.0F, 2.5F, 3.0F}, {1.5F, 2.0F, 2.5F, 3.0F, 3.5F}, {2.0F, 2.5F, 3.0F, 3.5F, 4.0F}, {2.5F, 3.0F, 3.5F, 4.0F, 4.5F}, {3.0F, 3.5F, 4.0F, 4.5F, 5.0F}, {3.5F, 4.0F, 4.5F, 5.0F, 5.5F}, {4.0F, 4.5F, 5.0F, 5.5F, 6.0F} }; for (int j = 0; j < 8; j++) { for (int i = 0; i < 4; i++) { int x = i * 4 / 2; int y = j * 2 / 2; assertEquals(interpolated[j][i], grid.getPixelFloat(x, y), _eps); } } }
final int y = (int) intAcces[1]; final float expected = intAcces[2]; final float actual = grid.getPixelFloat(x, y); assertEquals("loop counter i = " + i, expected, actual, 1e-5f);
final int y = (int) intAcces[1]; final float expected = intAcces[2]; final float actual = grid.getPixelFloat(x, y); assertEquals("loop counter i = " + i, expected, actual, 1e-5f);
for (int yCoordinate = y; yCoordinate < y + h; yCoordinate++) { for (int xCoordinate = x; xCoordinate < x + w; xCoordinate++) { pixels[i] = getPixelFloat(xCoordinate, yCoordinate); i++;