Commit 9862ed28 authored by Ken Edmundson's avatar Ken Edmundson
Browse files

mvic frame camera updates

parent c7f1fbff
Loading
Loading
Loading
Loading
+0 −196
Original line number Diff line number Diff line
/**
 * @file
 *
 *   Unless noted otherwise, the portions of Isis written by the USGS are public
 *   domain. See individual third-party library and package descriptions for 
 *   intellectual property information,user agreements, and related information.
 *
 *   Although Isis has been used by the USGS, no warranty, expressed or implied,
 *   is made by the USGS as to the accuracy and functioning of such software 
 *   and related material nor shall the fact of distribution constitute any such 
 *   warranty, and no responsibility is assumed by the USGS in connection 
 *   therewith.
 *
 *   For additional information, launch
 *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see 
 *   the Privacy & Disclaimers page on the Isis website,
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */
#include <cmath>
#include <iostream>

#include <QDebug>

#include <boost/math/special_functions/legendre.hpp>

#include "Constants.h"
#include "FunctionTools.h"
#include "IString.h"
#include "MvicCameraDistortionMap.h"

using namespace std;
using namespace Isis;

namespace Isis {
  /** Camera distortion map constructor
   *
   * Create a camera distortion map.  This class maps between distorted
   * and undistorted focal plane x/y's.  The default mapping is the
   * identity, that is, the focal plane x/y and undistorted focal plane
   * x/y will be identical.
   *
   * @param parent        the parent camera that will use this distortion map
   * @param zDirection    the direction of the focal plane Z-axis
   *                      (either 1 or -1)
   *
   */
  MvicCameraDistortionMap::MvicCameraDistortionMap(Camera *parent) :
                           CameraDistortionMap(parent, 1.0) {
    m_numDistCoef = 20;
    m_distCoefX.resize(m_numDistCoef);
    m_distCoefY.resize(m_numDistCoef);
  }

  /** Destructor
   */
  MvicCameraDistortionMap::~MvicCameraDistortionMap() {
  }


  /**
   * @param naifIkCode 
   */
  void MvicCameraDistortionMap::SetDistortion(const int naifIkCode) {

    //read the distortion coefs from the NAIF Kernels
    QString naifXKey = "INS-98903_DISTORTION_COEF_X";
    QString naifYKey = "INS-98903_DISTORTION_COEF_Y";
    qDebug()<<"Before Loop";
    for (int i=0; i < m_numDistCoef; i++) {
      qDebug()<<"num coef = "<<m_numDistCoef;
      double d = p_camera->getDouble(naifXKey,i);;
      qDebug()<<"naifXKey = "<<naifXKey<<"     d = "<<d;
      m_distCoefX[i] = p_camera->getDouble(naifXKey,i);
      qDebug()<<"after X";
      m_distCoefY[i] = p_camera->getDouble(naifYKey,i);
      qDebug()<<"after Y";
    }
    qDebug()<<"After Loop";
    // Set boresight (typically referred to as the principal point offset by photogrammetrists -
    // what are photogrammetrist???). The boresights in the ik are based on -X boresight.  In Isis
    // boresight needs to be in Z.
    m_boreX = 0.0;
    m_boreY = 0.0;
  }


  /** Compute undistorted focal plane x/y
   *
   * Compute undistorted focal plane x/y given a distorted focal plane x/y.
   *
   * @param dx distorted focal plane x in millimeters
   * @param dy distorted focal plane y in millimeters
   *
   * @return if the conversion was successful
   * @see SetDistortion
   */
  bool MvicCameraDistortionMap::SetFocalPlane(const double dx, const double dy) {
/*
    p_focalPlaneX = dx;
    p_focalPlaneY = dy;

    // scale dx and dy to lie between -1 and 1 (requirement for Legendre Polynomials, man)
    double dx_scaled = dx - 65.312/2;
    double dy_scaled = dy - 1.664/2;

    double lpx0, lpx1, lpx2, lpx3, lpx4, lpx5;
    double lpy0, lpy1, lpy2, lpy3, lpy4, lpy5;

    lpx0 = boost::math::legendre_p(0,dx_scaled);
    lpx1 = boost::math::legendre_p(1,dx_scaled);
    lpx2 = boost::math::legendre_p(2,dx_scaled);
    lpx3 = boost::math::legendre_p(3,dx_scaled);
    lpx4 = boost::math::legendre_p(4,dx_scaled);
    lpx5 = boost::math::legendre_p(5,dx_scaled);
    lpy0 = boost::math::legendre_p(0,dy_scaled);
    lpy1 = boost::math::legendre_p(1,dy_scaled);
    lpy2 = boost::math::legendre_p(2,dy_scaled);
    lpy3 = boost::math::legendre_p(3,dy_scaled);
    lpy4 = boost::math::legendre_p(4,dy_scaled);
    lpy5 = boost::math::legendre_p(5,dy_scaled);

//  double deltax =
//  double deltay =

    p_undistortedFocalPlaneX =  m_boreX +
        m_distCoefX[0] +  dx*m_distCoefX[1] + dx*(m_distCoefX[2]*m_distCoefX[2]) +
        dx*(m_distCoefX[3] * m_distCoefX[3] * m_distCoefX[3]);
    p_undistortedFocalPlaneY =  m_boreY +
        m_distCoefY[0] +  dy*m_distCoefY[1] + dy*(m_distCoefY[2]*m_distCoefY[2]) +
        dy*(m_distCoefY[3] * m_distCoefY[3] * m_distCoefY[3]);
//  p_undistortedFocalPlaneY =  m_boreY +
//    m_distCoefY[0] + dy*(m_distCoefY[1] + dy*(m_distCoefY[2] + dy*m_distCoefY[3])) + dy;

      qDebug() << "distorted: " << dx << " " << dy;
      qDebug() << "undistorted: " << p_undistortedFocalPlaneX << " " << p_undistortedFocalPlaneY;
*/
    return true;
  }


  /** Compute distorted focal plane x/y
   *
   * Compute distorted focal plane x/y given an undistorted focal plane x/y.
   *
   * @param ux undistorted focal plane x in millimeters
   * @param uy undistorted focal plane y in millimeters
   *
   * @return if the conversion was successful
   * @see SetDistortion
   */
  bool MvicCameraDistortionMap::SetUndistortedFocalPlane(const double ux, const double uy) {
/*
    // image coordinates prior to introducing distortion
    p_undistortedFocalPlaneX = ux;
    p_undistortedFocalPlaneY = uy;

    //std::cout << "Distortionless : " << p_undistortedFocalPlaneX << " " << p_undistortedFocalPlaneY << "\n";

    //cubic distortion model
    //use the cubic equation to find the distorted Y value
    double a,b,c; //coefficients of the cubic (coef x^3 ==1)

    a = m_distCoefY[2] / m_distCoefY[3];
    b = (1.0 + m_distCoefY[1]) / m_distCoefY[3];
    c = (m_distCoefY[0] + m_boreY - uy) / m_distCoefY[3];

    QList<double> roots = FunctionTools::realCubicRoots(1.0,a,b,c);

    if (roots.size() == 1) { //one root
      p_focalPlaneY = roots[0];
    }
    else {  //pick the root closest to the orginal value
      QList<double> delta;

      //store all the distance from undistored to focal plane
      for (int i=0;i<roots.size();i++)
        delta << fabs(roots[i]-uy);

      if ( roots.size() == 3) //three roots to choose among
        p_focalPlaneY = delta[0] < delta[1] ? 
                       (delta[0] < delta[2] ? roots[0]:roots[2]) : 
                       (delta[1] < delta[2] ? roots[1]:roots[2]) ;
      else  //two roots to choose between
        p_focalPlaneY = delta[0] < delta[1] ? roots[0]:roots[1]  ;
    }
     
    //now that we know the distortedY we can directly calculate the X
    p_focalPlaneX = ux - (m_boreX +m_distCoefX[0] + 
                    p_focalPlaneY*(m_distCoefX[1] + 
                    p_focalPlaneY*(m_distCoefX[2] +  
                    p_focalPlaneY* m_distCoefX[3])));
*/
    return true;
  }
}
+0 −62
Original line number Diff line number Diff line
#ifndef MvicCameraDistortionMap_h
#define MvicCameraDistortionMap_h
/** 
 * @file 
 *  
 *   Unless noted otherwise, the portions of Isis written by the USGS are public
 *   domain. See individual third-party library and package descriptions for
 *   intellectual property information,user agreements, and related information.
 *
 *   Although Isis has been used by the USGS, no warranty, expressed or implied,
 *   is made by the USGS as to the accuracy and functioning of such software
 *   and related material nor shall the fact of distribution constitute any such
 *   warranty, and no responsibility is assumed by the USGS in connection
 *   therewith.
 *
 *   For additional information, launch
 *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see
 *   the Privacy &amp; Disclaimers page on the Isis website,
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */

#include <vector>
#include "CameraDistortionMap.h"

namespace Isis {

  /** 
   *  Distort/undistort focal plane coordinates for New Horizons/MVIC
   *
   * Creates a map for adding/removing optical distortions
   * from the focal plane of a camera for the New Horizons/MVIC instrument.
   *
   * @ingroup SpiceInstrumentsAndCameras
   * @ingroup Mvic
   *
   * @see MvicCamera
   *
   * @author 2014-05-02 Ken Edmundson
   * @internal
   *   @history 2014-05-02 Ken Edmundson - Original Version
   */
  class MvicCameraDistortionMap : public CameraDistortionMap {
    public:
      MvicCameraDistortionMap(Camera *parent);

      //! Destroys the MvicMiCameraDistortionMap object.
      ~MvicCameraDistortionMap();

      void SetDistortion(const int naifIkCode);

      virtual bool SetFocalPlane(const double dx, const double dy);

      virtual bool SetUndistortedFocalPlane(const double ux, const double uy);
    private:
      std::vector<double> m_distCoefX;
      std::vector<double> m_distCoefY;
      double m_boreX, m_boreY;
      int m_numDistCoef;
  };
};
#endif
+3 −10
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ using namespace std;
namespace Isis {
  /**
   * Constructs a New Horizons MVIC Framing Camera object. The MVIC push-frame camera operates 
   * in "starring" mode, so it has been implemented as a framing camera rather than a push-frame. 
   * in "staring" mode, so it has been implemented as a framing camera rather than a push-frame.
   * The test images show the same part of the planet in each framelet, so the push-frame 
   * implementation will not work since the same lat/lon values are located in possibly every 
   * framelet. 
@@ -88,7 +88,7 @@ namespace Isis {
    // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
    // out the affine transforms from detector samp,line to focal plane x,y.
    CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
    focalMap->SetDetectorOrigin(2512.5, 64.5);
    focalMap->SetDetectorOrigin(2500.5, 64.5);

    // Read distortion coefficients and boresight offsets from the instrument kernels. Then
    // construct the distortion map.
@@ -98,20 +98,13 @@ namespace Isis {
    QString naifppKey = "INS-98900_PP_OFFSET";
    vector<double> distCoefX;
    vector<double> distCoefY;
    double boreX, boreY;

    for (int i=0; i < 20; i++) {
      distCoefX.push_back(getDouble(naifXKey,i));
      distCoefY.push_back(getDouble(naifYKey,i));
    }

    // Read boresight. Typically referred to as principal point offset (photogrammetry). Boresights
    // in the ik are based on -X boresight.  In Isis, the boresight needs to be in Z or -Z.

    boreX = getDouble(naifppKey,0);
    boreY = getDouble(naifppKey,1);

    new MvicFrameCameraDistortionMap(this, distCoefX, distCoefY, boreX, boreY);
    new MvicFrameCameraDistortionMap(this, distCoefX, distCoefY);

    // Setup the ground and sky map
    new CameraGroundMap(this);
+187 −71
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@
#include "IString.h"
#include "MvicFrameCameraDistortionMap.h"

#include "CameraFocalPlaneMap.h"


#include <QDebug>


@@ -38,33 +41,31 @@ using namespace Isis;
namespace Isis {
  /** Camera distortion map constructor
   *
   * Create a camera distortion map.  This class maps between distorted
   * and undistorted focal plane x/y's.  The default mapping is the
   * identity, that is, the focal plane x/y and undistorted focal plane
   * x/y will be identical.
   * This class maps between distorted and undistorted focal plane x/y's. The default mapping is the
   * identity, that is, the focal plane x/y and undistorted focal plane x/y will be identical.
   *
   * @param parent              the parent camera that will use this distortion map
   * @param zDirection          the direction of the focal plane Z-axis
   *                            (either 1 or -1)
   *
   * @param xDistortionCoeffs   distortion coefficients in x
   * @param yDistortionCoeffs   distortion coefficients in y
   */
  MvicFrameCameraDistortionMap::MvicFrameCameraDistortionMap(Camera *parent,
                                                             vector<double> xdistcoeffs,
                                                             vector<double> ydistcoeffs,
                                                             double borex, double borey) :
                                                             vector<double> xDistortionCoeffs,
                                                             vector<double> yDistortionCoeffs) :
    CameraDistortionMap(parent, 1.0) {

    m_numDistCoef = 20;
    m_distCoefX = xdistcoeffs;
    m_distCoefY = ydistcoeffs;
    m_xDistortionCoeffs = xDistortionCoeffs;
    m_yDistortionCoeffs = yDistortionCoeffs;

    m_boreX = borex;
    m_boreY = borey;
    double pixelPitch = p_camera->PixelPitch();

    m_detectorHalf_x = 0.5 * p_camera->Samples() * p_camera->PixelPitch(); // 32.656 mm
    m_detectorHalf_y = 0.5 * p_camera->Lines() * p_camera->PixelPitch();   //  0.832 mm
    m_focalPlaneHalf_x = 0.5 * p_camera->Samples() * pixelPitch; // 32.5 mm
    m_focalPlaneHalf_y = 0.5 * p_camera->Lines() * pixelPitch;   // 0.832 mm
  }


  /** Destructor
   */
  MvicFrameCameraDistortionMap::~MvicFrameCameraDistortionMap() {
@@ -75,7 +76,7 @@ namespace Isis {
   * Testing method to output corrections in x and y at pixel centers for entire focal plane.
   * Output in csv format for viewing/plotting in Excel.
   */
/*  bool MvicFrameCameraDistortionMap::outputdeltas() {
  bool MvicFrameCameraDistortionMap::outputDeltas() {

    QString ofname("mvic_frame_deltas.csv");
    std::ofstream fp_out(ofname.toAscii().data(), std::ios::out);
@@ -84,10 +85,23 @@ namespace Isis {

    char buf[1056];

    for (double y = -0.832; y <= 1.664; y += 0.013) {    // loop in y direction
      for (double x=-32.656; x <= 32.656; x += 0.013) {  // loop in x direction
        SetFocalPlane(x,y);
        sprintf(buf, "%lf,%lf,%lf,%lf\n", x, m_dx, y, m_dy);
    double deltax, deltay;

    for (double line = 0.5; line <= 128.5; line += 1.0) {    // loop in y direction
      for (double sample=0.5; sample <= 5000.5; sample += 1.0) {      // loop in x direction

        p_camera->FocalPlaneMap()->SetDetector(sample,line);

        double fplanex = p_camera->FocalPlaneMap()->FocalPlaneX();
        double fplaney = p_camera->FocalPlaneMap()->FocalPlaneY();

        SetFocalPlane(fplanex,fplaney);

        deltax = fplanex - p_undistortedFocalPlaneX;
        deltay = fplaney - p_undistortedFocalPlaneY;

        sprintf(buf, "%lf,%lf,%lf,%lf\n", sample, deltax/0.013, line, deltay/0.013);

        fp_out << buf;
      }
    }
@@ -96,7 +110,6 @@ namespace Isis {

    return true;
  }
*/


  /** Compute undistorted focal plane x/y
@@ -114,26 +127,73 @@ namespace Isis {
    p_focalPlaneX = dx;
    p_focalPlaneY = dy;

    // if x and/or y lie outside of the detector, do NOT apply distortion
    // set undistorted focal plane values to be identical to raw values
    if ((fabs(dx) > m_focalPlaneHalf_x) || (fabs(dy) > m_focalPlaneHalf_y)) {
      p_undistortedFocalPlaneX = dx;
      p_undistortedFocalPlaneY = dy;

      return true;
    }

    // shift from ISIS MVIC FT image coordinate system with +x to the left and +y down to
    // the desired system of +x to the right and +y up
    // e.g. negate x and y

    // scale x and y to lie in the range -1.0 to +1.0
    // this is requirement for Legendre Polynomials, man
    double xscaled = dx/m_detectorHalf_x;
    double yscaled = dy/m_detectorHalf_y;
    double xscaled = -dx/m_focalPlaneHalf_x;
    double yscaled = -dy/m_focalPlaneHalf_y;

    // compute distortion corrections in x and y using Legendre Polynomials
    // these corrections are also in the -1.0 to +1.0 range
    double deltax, deltay;
    computeDistortionCorrections(xscaled, yscaled, deltax, deltay);

    // apply the corrections
    // apply the corrections to original x,y
    xscaled += deltax;
    yscaled += deltay;

    // scale back from range of '-1.0 to +1.0' to the detector, '-32.656 to 32.656 mm'
    p_undistortedFocalPlaneX = xscaled * m_detectorHalf_x;
    p_undistortedFocalPlaneY = yscaled * m_detectorHalf_y;
    // scale back from range of '-1.0 to +1.0' to the detector, '-32.5 to 32.5 mm'
    p_undistortedFocalPlaneX = -xscaled * m_focalPlaneHalf_x;
    p_undistortedFocalPlaneY = -yscaled * m_focalPlaneHalf_y;

    return true;
  }
//  bool MvicFrameCameraDistortionMap::SetFocalPlane(const double dx, const double dy) {

//    p_focalPlaneX = dx;
//    p_focalPlaneY = dy;

//    // if x and/or y lie outside of the detector, do NOT apply distortion
//    // set undistorted focal plane values to be identical to raw values
//    if ((fabs(dx) > m_focalPlaneHalf_x) || (fabs(dy) > m_focalPlaneHalf_y)) {
//      p_undistortedFocalPlaneX = dx;
//      p_undistortedFocalPlaneY = dy;

//      return true;
//    }

//    // scale x and y to lie in the range -1.0 to +1.0
//    // this is requirement for Legendre Polynomials, man
//    double xscaled = dx/m_focalPlaneHalf_x;
//    double yscaled = dy/m_focalPlaneHalf_y;

//    // compute distortion corrections in x and y using Legendre Polynomials
//    // these corrections are also in the -1.0 to +1.0 range
//    double deltax, deltay;
//    computeDistortionCorrections(xscaled, yscaled, deltax, deltay);

//    // apply the corrections
//    xscaled += deltax;
//    yscaled += deltay;

//    // scale back from range of '-1.0 to +1.0' to the detector, '-32.656 to 32.656 mm'
//    p_undistortedFocalPlaneX = xscaled * m_focalPlaneHalf_x;
//    p_undistortedFocalPlaneY = yscaled * m_focalPlaneHalf_y;

//    return true;
//  }


  /** Compute distorted focal plane x/y
@@ -157,8 +217,8 @@ namespace Isis {
    double xScaledDistortion, yScaledDistortion;

    // scale undistorted coordinates to range of -1.0 to +1.0
    double xtScaled = ux/m_detectorHalf_x;
    double ytScaled = uy/m_detectorHalf_y;
    double xtScaled = -ux/m_focalPlaneHalf_x;
    double ytScaled = -uy/m_focalPlaneHalf_y;

    double uxScaled = xtScaled;
    double uyScaled = ytScaled;
@@ -193,9 +253,9 @@ namespace Isis {
    }

    if (bConverged) {
      // scale coordinates back to detector (-32.656 to +32.656)
      xtScaled *= m_detectorHalf_x;
      ytScaled *= m_detectorHalf_y;
      // scale coordinates back to detector (-32.5 to +32.5)
      xtScaled *= -m_focalPlaneHalf_x;
      ytScaled *= -m_focalPlaneHalf_y;

      // set distorted coordinates
      p_focalPlaneX = xtScaled;
@@ -204,6 +264,62 @@ namespace Isis {

    return bConverged;
  }
//  bool MvicFrameCameraDistortionMap::SetUndistortedFocalPlane(const double ux, const double uy) {

//    // image coordinates prior to introducing distortion
//    p_undistortedFocalPlaneX = ux;
//    p_undistortedFocalPlaneY = uy;

//    double xScaledDistortion, yScaledDistortion;

//    // scale undistorted coordinates to range of -1.0 to +1.0
//    double xtScaled = ux/m_focalPlaneHalf_x;
//    double ytScaled = uy/m_focalPlaneHalf_y;

//    double uxScaled = xtScaled;
//    double uyScaled = ytScaled;

//    double xScaledPrevious = 1000000.0;
//    double yScaledPrevious = 1000000.0;

//    double tolerance = 0.000001;

//    bool bConverged = false;

//    // iterating to introduce distortion...
//    // we stop when the difference between distorted coordinates
//    // in successive iterations is at or below the given tolerance
//    for( int i = 0; i < 50; i++ ) {

//      // compute distortion in x and y (scaled to -1.0 - +1.0) using Legendre Polynomials
//      computeDistortionCorrections(xtScaled, ytScaled, xScaledDistortion, yScaledDistortion);

//      // update scaled image coordinates
//      xtScaled = uxScaled - xScaledDistortion;
//      ytScaled = uyScaled - yScaledDistortion;

//      // check for convergence
//      if((fabs(xtScaled - xScaledPrevious) <= tolerance) && (fabs(ytScaled - yScaledPrevious) <= tolerance)) {
//        bConverged = true;
//        break;
//      }

//      xScaledPrevious = xtScaled;
//      yScaledPrevious = ytScaled;
//    }

//    if (bConverged) {
//      // scale coordinates back to detector (-32.656 to +32.656)
//      xtScaled *= m_focalPlaneHalf_x;
//      ytScaled *= m_focalPlaneHalf_y;

//      // set distorted coordinates
//      p_focalPlaneX = xtScaled;
//      p_focalPlaneY = ytScaled;
//    }

//    return bConverged;
//  }


  /** Compute distortion corrections in x and y direction
@@ -249,48 +365,48 @@ namespace Isis {
    }

    deltax =
       m_distCoefX[0] * lpx0 * lpy1 +
       m_distCoefX[1] * lpx1 * lpy0 +
       m_distCoefX[2] * lpx0 * lpy2 +
       m_distCoefX[3] * lpx1 * lpy1 +
       m_distCoefX[4] * lpx2 * lpy0 +
       m_distCoefX[5] * lpx0 * lpy3 +
       m_distCoefX[6] * lpx1 * lpy2 +
       m_distCoefX[7] * lpx2 * lpy1 +
       m_distCoefX[8] * lpx3 * lpy0 +
       m_distCoefX[9] * lpx0 * lpy4 +
      m_distCoefX[10] * lpx1 * lpy3 +
      m_distCoefX[11] * lpx2 * lpy2 +
      m_distCoefX[12] * lpx3 * lpy1 +
      m_distCoefX[13] * lpx4 * lpy0 +
      m_distCoefX[14] * lpx0 * lpy5 +
      m_distCoefX[15] * lpx1 * lpy4 +
      m_distCoefX[16] * lpx2 * lpy3 +
      m_distCoefX[17] * lpx3 * lpy2 +
      m_distCoefX[18] * lpx4 * lpy1 +
      m_distCoefX[19] * lpx5 * lpy0;
       m_xDistortionCoeffs[0] * lpx0 * lpy1 +
       m_xDistortionCoeffs[1] * lpx1 * lpy0 +
       m_xDistortionCoeffs[2] * lpx0 * lpy2 +
       m_xDistortionCoeffs[3] * lpx1 * lpy1 +
       m_xDistortionCoeffs[4] * lpx2 * lpy0 +
       m_xDistortionCoeffs[5] * lpx0 * lpy3 +
       m_xDistortionCoeffs[6] * lpx1 * lpy2 +
       m_xDistortionCoeffs[7] * lpx2 * lpy1 +
       m_xDistortionCoeffs[8] * lpx3 * lpy0 +
       m_xDistortionCoeffs[9] * lpx0 * lpy4 +
      m_xDistortionCoeffs[10] * lpx1 * lpy3 +
      m_xDistortionCoeffs[11] * lpx2 * lpy2 +
      m_xDistortionCoeffs[12] * lpx3 * lpy1 +
      m_xDistortionCoeffs[13] * lpx4 * lpy0 +
      m_xDistortionCoeffs[14] * lpx0 * lpy5 +
      m_xDistortionCoeffs[15] * lpx1 * lpy4 +
      m_xDistortionCoeffs[16] * lpx2 * lpy3 +
      m_xDistortionCoeffs[17] * lpx3 * lpy2 +
      m_xDistortionCoeffs[18] * lpx4 * lpy1 +
      m_xDistortionCoeffs[19] * lpx5 * lpy0;

    deltay =
      m_distCoefY[0] * lpx0 * lpy1 +
      m_distCoefY[1] * lpx1 * lpy0 +
      m_distCoefY[2] * lpx0 * lpy2 +
      m_distCoefY[3] * lpx1 * lpy1 +
      m_distCoefY[4] * lpx2 * lpy0 +
      m_distCoefY[5] * lpx0 * lpy3 +
      m_distCoefY[6] * lpx1 * lpy2 +
      m_distCoefY[7] * lpx2 * lpy1 +
      m_distCoefY[8] * lpx3 * lpy0 +
      m_distCoefY[9] * lpx0 * lpy4 +
     m_distCoefY[10] * lpx1 * lpy3 +
     m_distCoefY[11] * lpx2 * lpy2 +
     m_distCoefY[12] * lpx3 * lpy1 +
     m_distCoefY[13] * lpx4 * lpy0 +
     m_distCoefY[14] * lpx0 * lpy5 +
     m_distCoefY[15] * lpx1 * lpy4 +
     m_distCoefY[16] * lpx2 * lpy3 +
     m_distCoefY[17] * lpx3 * lpy2 +
     m_distCoefY[18] * lpx4 * lpy1 +
     m_distCoefY[19] * lpx5 * lpy0;
      m_yDistortionCoeffs[0] * lpx0 * lpy1 +
      m_yDistortionCoeffs[1] * lpx1 * lpy0 +
      m_yDistortionCoeffs[2] * lpx0 * lpy2 +
      m_yDistortionCoeffs[3] * lpx1 * lpy1 +
      m_yDistortionCoeffs[4] * lpx2 * lpy0 +
      m_yDistortionCoeffs[5] * lpx0 * lpy3 +
      m_yDistortionCoeffs[6] * lpx1 * lpy2 +
      m_yDistortionCoeffs[7] * lpx2 * lpy1 +
      m_yDistortionCoeffs[8] * lpx3 * lpy0 +
      m_yDistortionCoeffs[9] * lpx0 * lpy4 +
     m_yDistortionCoeffs[10] * lpx1 * lpy3 +
     m_yDistortionCoeffs[11] * lpx2 * lpy2 +
     m_yDistortionCoeffs[12] * lpx3 * lpy1 +
     m_yDistortionCoeffs[13] * lpx4 * lpy0 +
     m_yDistortionCoeffs[14] * lpx0 * lpy5 +
     m_yDistortionCoeffs[15] * lpx1 * lpy4 +
     m_yDistortionCoeffs[16] * lpx2 * lpy3 +
     m_yDistortionCoeffs[17] * lpx3 * lpy2 +
     m_yDistortionCoeffs[18] * lpx4 * lpy1 +
     m_yDistortionCoeffs[19] * lpx5 * lpy0;

    return true;
  }
+8 −9
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ namespace Isis {
   */
  class MvicFrameCameraDistortionMap : public CameraDistortionMap {
    public:
      MvicFrameCameraDistortionMap(Camera *parent, vector<double> xdistcoeffs,
                                   vector<double> ydistcoeffs, double borex, double borey);
      MvicFrameCameraDistortionMap(Camera *parent, vector<double> xDistortionCoeffs,
                                   vector<double> yDistortionCoeffs);

      ~MvicFrameCameraDistortionMap();

@@ -53,20 +53,19 @@ namespace Isis {

      virtual bool SetUndistortedFocalPlane(const double ux, const double uy);

      bool outputdeltas();
      bool outputDeltas(); // for debugging

    private:
      bool computeDistortionCorrections(const double xscaled, const double yscaled, double &deltax,
                                        double &deltay);

    private:
      std::vector<double> m_distCoefX;
      std::vector<double> m_distCoefY;
      double m_boreX, m_boreY;
      int m_numDistCoef;
      std::vector<double> m_xDistortionCoeffs; //!< distortion coefficients in x and y as determined
      std::vector<double> m_yDistortionCoeffs; //!< by Keith Harrison (Interface Control Document
                                               //!< section 10.3.1.2)

      double m_detectorHalf_x;
      double m_detectorHalf_y;
      double m_focalPlaneHalf_x;               //!< half of focal plane x and y dimensions in mm
      double m_focalPlaneHalf_y;
  };
};
#endif