Loading [MathJax]/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
KaguyaTcCameraDistortionMap.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include <QDebug>
10 #include <QtGlobal>
11 #include <QtMath>
12 
13 #include "KaguyaTcCameraDistortionMap.h"
14 
15 namespace Isis {
31  : CameraDistortionMap(parent) {
32  QString odtxkey = "INS" + toString(naifIkCode) + "_DISTORTION_COEF_X";
33  QString odtykey = "INS" + toString(naifIkCode) + "_DISTORTION_COEF_Y";
34  QString boresightkey = "INS" + toString(naifIkCode) + "_BORESIGHT";
35 
36  for(int i = 0; i < 4; ++i) {
37  p_odkx.push_back(p_camera->getDouble(odtxkey, i));
38  p_odky.push_back(p_camera->getDouble(odtykey, i));
39  }
40 
41  // add boresight x and y to coefficients vector
42  p_odkx[0] = p_odkx[0] + p_camera->getDouble(boresightkey, 0);
43  p_odky[0] = p_odky[0] + p_camera->getDouble(boresightkey, 1);
44  }
45 
46 
47 
52  }
53 
54 
90  bool KaguyaTcCameraDistortionMap::SetFocalPlane(double dx, double dy) {
91  p_focalPlaneX = dx;
92  p_focalPlaneY = dy;
93 
94  double x = dx;
95  double y = dy;
96 
97  double r2 = x*x + y*y;
98  double r = qSqrt(r2);
99  double r3 = r2 * r;
100 
101  double dr_x = p_odkx[0] + p_odkx[1] * r + p_odkx[2] * r2 + p_odkx[3] * r3; //add boresight offset
102  double dr_y = p_odky[0] + p_odky[1] * r + p_odky[2] * r2 + p_odky[3] * r3; //add boresight offset
103 
104  p_undistortedFocalPlaneX = x + dr_x;
105  p_undistortedFocalPlaneY = y + dr_y;
106 
107  return true;
108  }
109 
110 
131  const double uy) {
132 
135 
136  double xt = ux;
137  double yt = uy;
138 
139  double xx, yy, r, rr, rrr, dr_x, dr_y;
140  double xdistortion, ydistortion;
141  double xdistorted, ydistorted;
142  double xprevious, yprevious;
143 
144  xprevious = 1000000.0;
145  yprevious = 1000000.0;
146 
147  double tolerance = 0.000001;
148  bool bConverged = false;
149 
150  // Iterating to introduce distortion...
151  // We stop when the difference between distorted coordinates
152  // in successive iterations is below the given tolerance
153  for (int i = 0; i < 50; i++) {
154  xx = xt * xt;
155  yy = yt * yt;
156  rr = xx + yy;
157  r = qSqrt(rr);
158  rrr = rr * r;
159 
160  // Radial distortion
161  // dr is the radial distortion contribution
162  dr_x = p_odkx[0] + p_odkx[1] * r + p_odkx[2] * rr + p_odkx[3] * rrr; // why did hayabusa have a -1
163  dr_y = p_odky[0] + p_odky[1] * r + p_odky[2] * rr + p_odky[3] * rrr; // why did hayabusa have a -1
164 
165  // Distortion at the current point location
166  xdistortion = dr_x;
167  ydistortion = dr_y;
168 
169  // updated image coordinates
170  xt = ux - xdistortion;
171  yt = uy - ydistortion;
172 
173  // distorted point corrected for principal point
174  xdistorted = xt;
175  ydistorted = yt;
176 
177  // check for convergence
178  if ((fabs(xt - xprevious) < tolerance) && (fabs(yt - yprevious) < tolerance)) {
179  bConverged = true;
180  break;
181  }
182 
183  xprevious = xt;
184  yprevious = yt;
185  }
186 
187  if (bConverged) {
188  p_focalPlaneX = xdistorted;
189  p_focalPlaneY = ydistorted;
190  }
191 
192  return bConverged;
193  }
194 }
Isis::CameraDistortionMap::p_focalPlaneX
double p_focalPlaneX
Distorted focal plane x.
Definition: CameraDistortionMap.h:65
Isis::CameraDistortionMap::p_undistortedFocalPlaneY
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Definition: CameraDistortionMap.h:68
Isis::KaguyaTcCameraDistortionMap::KaguyaTcCameraDistortionMap
KaguyaTcCameraDistortionMap(Camera *parent, int naifIkCode)
Kaguya TC Camera distortion map constructor.
Definition: KaguyaTcCameraDistortionMap.cpp:30
Isis::CameraDistortionMap::p_undistortedFocalPlaneX
double p_undistortedFocalPlaneX
Undistorted focal plane x.
Definition: CameraDistortionMap.h:67
Isis::KaguyaTcCameraDistortionMap::p_odkx
std::vector< double > p_odkx
distortion x coefficients
Definition: KaguyaTcCameraDistortionMap.h:41
Isis::Camera
Definition: Camera.h:236
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::CameraDistortionMap::p_camera
Camera * p_camera
The camera to distort/undistort.
Definition: CameraDistortionMap.h:63
Isis::KaguyaTcCameraDistortionMap::~KaguyaTcCameraDistortionMap
virtual ~KaguyaTcCameraDistortionMap()
Destructor.
Definition: KaguyaTcCameraDistortionMap.cpp:51
Isis::CameraDistortionMap
Distort/undistort focal plane coordinates.
Definition: CameraDistortionMap.h:41
Isis::KaguyaTcCameraDistortionMap::p_odky
std::vector< double > p_odky
distortion y coefficients
Definition: KaguyaTcCameraDistortionMap.h:42
Isis::KaguyaTcCameraDistortionMap::SetFocalPlane
virtual bool SetFocalPlane(double dx, double dy)
Compute undistorted focal plane x/y.
Definition: KaguyaTcCameraDistortionMap.cpp:90
Isis::Spice::getDouble
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1039
Isis::KaguyaTcCameraDistortionMap::SetUndistortedFocalPlane
virtual bool SetUndistortedFocalPlane(double ux, double uy)
Compute distorted focal plane x/y.
Definition: KaguyaTcCameraDistortionMap.cpp:130
Isis::CameraDistortionMap::p_focalPlaneY
double p_focalPlaneY
Distorted focal plane y.
Definition: CameraDistortionMap.h:66
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:45