public QuadInterpolator(final TiePointGrid tpg) { subSamplinX = tpg.getSubSamplingX(); subSamplinY = tpg.getSubSamplingY(); final int width = tpg.getGridWidth();
for (int j = 0; j < w; j++) { final int k = iw + j; final int x = (int) (j * tpg.getSubSamplingX()); sampleIndexArray[k][0] = 1.0; sampleIndexArray[k][1] = (double) (x);
private void setIPFTiePointGridRasterData(final TiePointGrid tpg) { final int gridWidth = 11; final int gridHeight = 11; final int subSamplingX = (int) tpg.getSubSamplingX(); final float[] rangeTime = new float[gridWidth * gridHeight]; final double polyCoef[] = new double[4]; final BinaryRecord sceneRec = leaderFile.getSceneRecord(); if (rangeDist == null) { rangeDist = new float[gridWidth * gridHeight]; polyCoef[0] = sceneRec.getAttributeDouble("Image range to slant constant term"); polyCoef[1] = sceneRec.getAttributeDouble("Image range to slant linear term"); polyCoef[2] = sceneRec.getAttributeDouble("Image range to slant quadratic term"); polyCoef[3] = sceneRec.getAttributeDouble("Image range to slant cubic term"); double rangePixelSpacing = sceneRec.getAttributeDouble("Pixel spacing"); int k = 0; for (int j = 0; j < gridHeight; j++) { for (int i = 0; i < gridWidth; i++) { double x = (double) (i * subSamplingX) * rangePixelSpacing / 1000.0; x = x - rangePixelSpacing / 2000.0; //polynomial has convention pixel-is-point rangeDist[k++] = (float) ((polyCoef[0] + polyCoef[1] * x + polyCoef[2] * x * x + polyCoef[3] * x * x * x) * 1000.0); } } // get slant range time in nanoseconds from range distance in meters for (k = 0; k < rangeDist.length; k++) { rangeTime[k] = (float) (rangeDist[k] / Constants.halfLightSpeed * Constants.oneBillion); // in ns } tpg.setDataElems(rangeTime); } }
/** * Compute polynomial coefficients for quadratic interpolation. For each tie point record, 3 coefficients * are computed. The 3 coefficients are saved in a row in _quadraticInterpCoeffs as {a0, a1, a2}. The * quadratic polynomial is given as f(x) = a0 + a1*x + a2*x^2. */ private synchronized void computeQuadraticInterpCoeffs() { if (quadraticInterpCoeffs != null) return; final int numCoeff = 3; final int width = tpg.getGridWidth(); final int height = tpg.getGridHeight(); final double[][] sampleIndexArray = new double[width][numCoeff]; for (int c = 0; c < width; c++) { final int x = (int) (tpg.getOffsetX() + c * tpg.getSubSamplingX()); sampleIndexArray[c][0] = 1.0; sampleIndexArray[c][1] = (double) (x); sampleIndexArray[c][2] = (double) (x * x); } final Matrix A = new Matrix(sampleIndexArray); quadraticInterpCoeffs = new double[height][numCoeff]; final double[] tiePointArray = new double[width]; for (int r = 0; r < height; r++) { final int rwidth = r * width; for (int c = 0; c < width; c++) { tiePointArray[c] = (double) (tiePoints[rwidth + c]); } final Matrix b = new Matrix(tiePointArray, width); final Matrix x = A.solve(b); quadraticInterpCoeffs[r] = x.getColumnPackedCopy(); } }
addEntry("Offset X:", String.valueOf(grid.getOffsetX()), "pixels"); addEntry("Offset Y:", String.valueOf(grid.getOffsetY()), "pixels"); addEntry("Sub-sampling X:", String.valueOf(grid.getSubSamplingX()), "pixels"); addEntry("Sub-sampling Y:", String.valueOf(grid.getSubSamplingY()), "pixels"); addEntry("Raster width:", String.valueOf(grid.getRasterWidth()), "pixels");
final int subSamplingX = (int) tpg.getSubSamplingX(); final float[] rangeTime = new float[gridWidth * gridHeight];