Пример #1
0
Файл: CPM.java Проект: fpl/s1tbx
  public CPM(
      final int cpmDegree,
      final int maxIterations,
      final float criticalValue,
      final Window normalWindow,
      final ProductNodeGroup<Placemark> masterGCPGroup,
      ProductNodeGroup<Placemark> slaveGCPGroup) {

    logger.setLevel(Level.WARNING);

    this.numObservations = slaveGCPGroup.getNodeCount();
    this.cpmDegree = cpmDegree;
    this.numUnknowns = PolyUtils.numberOfCoefficients(cpmDegree);

    if (numObservations < numUnknowns) {
      this.noRedundancy = true;
      logger.severe("Number of windows > threshold is smaller than parameters solved for.");
    }

    if (!noRedundancy) {

      this.maxIterations = maxIterations;
      this.criticalValue = criticalValue;
      this.cpmWeight = "none";

      this.xCoef = new double[numUnknowns];
      this.yCoef = new double[numUnknowns];
      this.xCoefJai = new double[numUnknowns];
      this.yCoefJai = new double[numUnknowns];

      this.normWin = normalWindow; // master dimensions

      double tempSum = 0.0d;

      // populate arrays and collections
      for (int i = 0; i < numObservations; i++) {

        slaveGCPList.add(slaveGCPGroup.get(i));
        final Placemark sPin = slaveGCPList.get(i);
        final PixelPos sGCPPos = sPin.getPixelPos();
        // System.out.println("WARP: slave gcp[" + i + "] = " + "(" + sGCPPos.x + "," + sGCPPos.y +
        // ")");

        final Placemark mPin = masterGCPGroup.get(sPin.getName());
        final PixelPos mGCPPos = mPin.getPixelPos();
        // System.out.println("WARP: master gcp[" + i + "] = " + "(" + mGCPPos.x + "," + mGCPPos.y +
        // ")");

        index.add(i);
        yMaster.add(mGCPPos.y);
        xMaster.add(mGCPPos.x);
        ySlave.add(sGCPPos.y);
        xSlave.add(sGCPPos.x);
        yOffset.add(sGCPPos.y - mGCPPos.y);
        xOffset.add(sGCPPos.x - mGCPPos.x);
        coherence.add(1);

        // check if master and slave coordinates are identical, if yes CPM coefficients will be set
        // directly, no need to compute them using estimators because most likely they would produce
        // incorrect result due to ill conditioned matrix.
        tempSum += Math.abs(xOffset.getQuick(i) + yOffset.getQuick(i));
      }

      if (tempSum < 0.01) {
        this.doEstimation = false;
      }
    }
  }