Unverified Commit 8c239fad authored by Stuart Sides's avatar Stuart Sides Committed by GitHub
Browse files

Merge pull request #545 from makaylas/m05247_m05248

Fixed two bug with AutoReg. One occurs with one dimensional pattern c…
parents 4b0e3206 f75a84d7
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -671,10 +671,12 @@ namespace Isis {
    // Before we attempt to apply the reduction factor, we need to make sure
    // we won't produce a chip of a bad size.
    // ----------------------------------------------------------------------
    if (p_reduceFactor != 1) {
      if(gradientPatternChip.Samples() / p_reduceFactor < 2 || gradientPatternChip.Lines() / p_reduceFactor < 2) {
        string msg = "Reduction factor is too large";
        throw IException(IException::User, msg, _FILEINFO_);
      }
    }

    // Establish the center search tack point as best pixel to start for the
    // adaptive algorithm prior to reduction.
@@ -852,14 +854,20 @@ namespace Isis {
      if (!window.IsValid(100.0 * 2.1 / 3.0)) {
        p_surfaceModelNotEnoughValidDataCount++;
        p_registrationStatus = SurfaceModelNotEnoughValidData;
        p_chipSample = p_bestSamp;
        p_chipLine = p_bestLine;
        return SurfaceModelNotEnoughValidData;
      }

      // Now that we know we have enough data to model the surface we call
      // SetSubpixelPosition() to get the sub-pixel accuracy we are looking for.
      bool computedSubPixel = SetSubpixelPosition(window);
      if (!computedSubPixel)
        return p_registrationStatus;
      if (!computedSubPixel) {
        p_chipSample = p_bestSamp;
        p_chipLine = p_bestLine;
        p_registrationStatus = SurfaceModelSolutionInvalid;
        return SurfaceModelSolutionInvalid;
      }
      
      // See if the surface model solution moved too far from our whole pixel
      // solution
@@ -870,18 +878,20 @@ namespace Isis {

        p_surfaceModelDistanceInvalidCount++;
        p_registrationStatus = SurfaceModelDistanceInvalid;
        p_chipSample = p_bestSamp;
        p_chipLine = p_bestLine;
        return SurfaceModelDistanceInvalid;
      }

      p_registrationStatus = SuccessSubPixel;
      return SuccessSubPixel;
    }
    else {
      p_chipSample = p_bestSamp;
      p_chipLine = p_bestLine;
      p_registrationStatus = SuccessPixel;
      return SuccessPixel;
    }

    return p_registrationStatus;
  }


@@ -1320,3 +1330,4 @@ namespace Isis {
    return reg;
  }
}
+6 −0
Original line number Diff line number Diff line
@@ -173,6 +173,12 @@ namespace Isis {
   *             give useful results due to the 2x2 matrix it uses.
   *    @history 2012-01-05 Travis Addair - Added separate variables for Whole
   *             Pixel Correlation and Subpixel Correlation.
   *    @history 2018-07-27 Makayla Shepherd - Fixed a bug that made registration fail for
   *                            one dimensional pattern chips. Fixes #5247.
   *    @history 2018-07-27 Makayla Shepherd - Fixed a bug that upon sub-pixel registration failure
   *                            caused the previous registration to be returned. If sub-pixel 
   *                            registration fails now it will return to the whole pixel 
   *                            registration values. Fixes #5248.
   */
  class AutoReg {
    public: