示例#1
0
  private WarpPolynomial createWarp(
      int dstWidth,
      int dstHeight,
      ICRS srcCRS,
      RasterGeoReference srcREnv,
      RasterGeoReference dstREnv)
      throws TransformationException {
    int k = 0;
    // create/calculate reference points
    float dx = (dstWidth - 1) / (float) (refPointsGridSize - 1);
    float dy = (dstHeight - 1) / (float) (refPointsGridSize - 1);
    float[] srcCoords = new float[refPointsGridSize * refPointsGridSize * 2];
    float[] dstCoords = new float[refPointsGridSize * refPointsGridSize * 2];
    List<Point3d> points = new ArrayList<Point3d>(refPointsGridSize * refPointsGridSize);
    for (int j = 0; j < refPointsGridSize; j++) {
      for (int i = 0; i < refPointsGridSize; i++) {
        dstCoords[k] = i * dx;
        dstCoords[k + 1] = j * dy;
        double[] dstWCoords =
            dstREnv.getWorldCoordinate((int) dstCoords[k], (int) dstCoords[k + 1]);
        points.add(new Point3d(dstWCoords[0], dstWCoords[1], Double.NaN));
        k += 2;
      }
    }
    List<Point3d> resultList = transformDstToSrc(srcCRS, points);

    k = 0;
    for (Point3d point : resultList) {
      double[] srcRCoords = srcREnv.getRasterCoordinateUnrounded(point.x, point.y);
      srcCoords[k] = (float) srcRCoords[0];
      srcCoords[k + 1] = (float) srcRCoords[1];
      k += 2;
    }

    // create a best fit polynomial for out grid
    WarpPolynomial warp =
        WarpPolynomial.createWarp(
            srcCoords, 0, dstCoords, 0, srcCoords.length, 1f, 1f, 1f, 1f, polynomialOrder);
    return warp;
  }
示例#2
0
文件: CPM.java 项目: fpl/s1tbx
  public void wrapJaiWarpPolynomial() {

    logger.info("Start JAI wrapper");

    float[] xyMaster = new float[2 * numObservations];
    float[] xySlave = new float[2 * numObservations];

    // work only with survived points!
    for (int i = 0; i < numObservations; i++) {
      final int j = 2 * i;
      xyMaster[j] = (float) xMaster.getQuick(i);
      xyMaster[j + 1] = (float) yMaster.getQuick(i);

      //            if (!demRefinement) {
      xySlave[j] = (float) (xSlave.getQuick(i));
      xySlave[j + 1] = (float) (ySlave.getQuick(i));
      //            } else {
      //                xySlave[j] = (float) (xSlaveGeometry.getQuick(i));
      //                xySlave[j + 1] = (float) (ySlaveGeometry.getQuick(i));
      //            }
    }

    jaiWarp =
        WarpPolynomial.createWarp(
            xySlave, 0, xyMaster, 0, 2 * numObservations, 1f, 1f, 1f, 1f, cpmDegree);

    float[] xCoefJai_TEMP = jaiWarp.getXCoeffs();
    float[] yCoefJai_TEMP = jaiWarp.getYCoeffs();
    final int size = xCoefJai_TEMP.length;
    xCoefJai = new double[size];
    yCoefJai = new double[size];

    for (int i = 0; i < size; ++i) {
      xCoefJai[i] = xCoefJai_TEMP[i];
      yCoefJai[i] = yCoefJai_TEMP[i];
    }
  }