Unverified Commit b9f6d29a authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Fixed rolling shutter applyJitter (#4976)

parent 95b1fcfc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ release.
### Fixed
- Added check to determine if poles were a valid projection point in ImagePolygon when generating footprint for a map projected image. [#4390](https://github.com/USGS-Astrogeology/ISIS3/issues/4390)
- Fixed the Mars Express HRSC SRC camera and serial number to use the StartTime instead of the StartClockCount  [#4803](https://github.com/USGS-Astrogeology/ISIS3/issues/4803)
- Fixed algorithm for applying rolling shutter jitter. Matches implementation in USGSCSM.


## [7.0.0] - 2022-02-11
+12 −10
Original line number Diff line number Diff line
@@ -112,6 +112,13 @@ namespace Isis {

  /**
   * Iteratively finds a solution to "apply" jitter to an image coordinate.
   * Each iteration adds jitter to the original image coordinate until it finds
   * an image coordinate that maps back to to the original image coordinate when
   * jitter is removed. This is similar to how we handle applying radial distortion.
   *
   * Note: If the jitter varies significantly (>1 pixel difference) then it is possible
   * for there to be multiple solutions to the inverse problem and it is impossible to
   * know which one to choose.
   *
   * @param sample Image sample to apply jitter to.
   * @param line Image line to apply jitter to.
@@ -127,16 +134,11 @@ namespace Isis {
    int iterations = 0;
    int maxIterations = 50;

    p_detectorSample = sample;
    p_detectorLine   = line;
    p_parentSample   = (p_detectorSample - p_ss) / p_detectorSampleSumming + 1.0;
    p_parentLine     = (p_detectorLine   - p_sl) / p_detectorLineSumming   + 1.0;

    while((qFabs(sample - currentSample) < 1e-7) &&
          (qFabs(line - currentLine) < 1e-7)) {
    while((qFabs(sample - jittered.first) > 1e-7) ||
          (qFabs(line - jittered.second) > 1e-7)) {

      currentSample = (currentSample - jittered.first);
      currentLine = (currentLine - jittered.second);
      currentSample = sample + (currentSample - jittered.first);
      currentLine = line + (currentLine - jittered.second);

      jittered = removeJitter(currentSample, currentLine);

@@ -148,7 +150,7 @@ namespace Isis {

    }

    return std::pair<double, double>(sample + currentSample, line + currentLine);
    return std::pair<double, double>(currentSample, currentLine);
  }

  /**
+6 −5
Original line number Diff line number Diff line
@@ -26,8 +26,9 @@ TEST(RollingShutterCameraDetectorMapTests, ApplyAndRemoveJitter) {
    for (int sample = 1; sample <= 3; sample++) {
      std::pair<double, double> removed = detectorMap.removeJitter(sample, line);
      std::pair<double, double> applied = detectorMap.applyJitter(removed.first, removed.second);
      EXPECT_NEAR(removed.second, applied.second, 0.1);
      EXPECT_NEAR(removed.first, applied.first, 0.1);
      // Test tolerances match iteration tolerance in RollingShutterCameraDetectorMap::applyJitter
      EXPECT_NEAR(sample, applied.first, 1e-7);
      EXPECT_NEAR(line, applied.second, 1e-7);
    }
  }
}