Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
JunoDistortionMap.cpp
1
6
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "IString.h"
10#include "JunoDistortionMap.h"
11
12namespace Isis {
28
29
35
36
64 void JunoDistortionMap::SetDistortion(int naifIkCode) {
65
66 // Use the pixel pitch to scale k1 and k2 coefficients to operate in focal
67 // plane coordinates (millimeters). The coefficients found in the kernels
68 // are based on detector coordinates (pixels).
69
70 double pp = p_camera->PixelPitch();
71 double p2 = pp * pp;
72
73 // Currently k0 is non-existant in kernels (i.e equals zero). The try is
74 // here in case this coefficient is needed for future distortion models.
75 try {
76 QString odk0 = "INS" + toString(naifIkCode) + "_DISTORTION_K0";
77 p_odk.push_back(p_camera->Spice::getDouble(odk0));
78
79 }
80 catch (IException &e) {
81 p_odk.push_back(0.0);
82 }
83
84 QString odk1 = "INS" + toString(naifIkCode) + "_DISTORTION_K1";
85 p_odk.push_back(p_camera->Spice::getDouble(odk1) / p2);
86 QString odk2 = "INS" + toString(naifIkCode) + "_DISTORTION_K2";
87 p_odk.push_back(p_camera->Spice::getDouble(odk2) / (p2 * p2));
88 }
89
90
110 const double uy) {
111
114
115 // Compute the distance from the focal plane center
116 double r2 = (ux * ux) + (uy * uy);
117
118 // The equation given in the IK computes the undistorted focal plane
119 // ux = dx * (1 + k1*r^2), r^2 = dx^2 + dy^2
120 double dr = 1 + p_odk[0] + p_odk[1]*r2 + p_odk[2]*r2*r2;
121 p_focalPlaneX = ux * dr;
122 p_focalPlaneY = uy * dr;
123
124 return true;
125
126 }
127
128
147 double dy) {
148 p_focalPlaneX = dx;
149 p_focalPlaneY = dy;
150
151 // Get the distance from the focal plane center
152 double r2 = (dx * dx) + (dy * dy);
153
154 bool converged = false;
155 int i = 0;
156 int maximumIterations = 15;
157 double tolerance = p_camera->PixelPitch() / 100.0;
158 double uxEstimate = dx;
159 double uyEstimate = dy;
160 double uxPrev = dx;
161 double uyPrev = dy;
162 double xDistortion = 0.0;
163 double yDistortion = 0.0;
164 double dr = 0.0;
165 while (!converged) {
166 dr = p_odk[0] + p_odk[1]*r2 + p_odk[2]*r2*r2;
167 xDistortion = uxEstimate * dr;
168 yDistortion = uyEstimate * dr;
169 uxEstimate = dx - xDistortion;
170 uyEstimate = dy - yDistortion;
171 i++;
172 if (fabs(uxEstimate - uxPrev) < tolerance &&
173 fabs(uyEstimate - uyPrev) < tolerance ) {
174 converged = true;
175 }
176 // If doesn't converge, don't do correction
177 if (i > maximumIterations) {
180 break;
181 }
182 r2 = (uxEstimate * uxEstimate) + (uyEstimate * uyEstimate);
183 uxPrev = uxEstimate;
184 uyPrev = uyEstimate;
185 }
186 p_undistortedFocalPlaneX = uxEstimate;
187 p_undistortedFocalPlaneY = uyEstimate;
188 return true;
189 }
190
191}
CameraDistortionMap(Camera *parent, double zDirection=1.0)
Camera distortion map constructor.
double p_focalPlaneX
Distorted focal plane x.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
std::vector< double > p_odk
Vector of distortion coefficients.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Camera * p_camera
The camera to distort/undistort.
double p_focalPlaneY
Distorted focal plane y.
virtual void SetDistortion(int naifIkCode)
Load distortion coefficients for JunoCam.
virtual bool SetFocalPlane(double dx, double dy)
Compute undistorted focal plane x/y.
virtual ~JunoDistortionMap()
Destructor.
virtual bool SetUndistortedFocalPlane(double ux, double uy)
Compute distorted focal plane x/y.
JunoDistortionMap(Camera *parent)
Juno JunoCam distortion map constructor.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.