12#include "MarciDistortionMap.h"
28 QString odkkey =
"INS" +
toString(naifIkCode) +
"_DISTORTION_COEFFS";
30 for(
int i = 0; i < 4; i++) {
54 double radialDist2 = (dxPix * dxPix) + (dyPix * dyPix);
57 double radialDist4 = radialDist2 * radialDist2;
58 double radialDist6 = radialDist4 * radialDist2;
60 double uRadialDist =
p_odk[0] + radialDist2 *
p_odk[1] +
61 radialDist4 *
p_odk[2] +
62 radialDist6 *
p_odk[3];
65 double uxPix = dxPix * uRadialDist;
66 double uyPix = dyPix * uRadialDist;
92 double uxPix = ux /
p_camera->PixelPitch();
93 double uyPix = uy /
p_camera->PixelPitch();
95 double dxPix = GuessDx(uxPix);
99 double Ru = sqrt((uxPix * uxPix) + (uyPix * uyPix));
104 double Rd = sqrt((dxPix * dxPix) + (dyPix * dyPix));
106 while(fabs(delta) > 1E-9) {
107 if(fabs(delta) > 1E30 || iter > 50) {
111 double Rd2 = Rd * Rd;
112 double Rd3 = Rd2 * Rd;
113 double Rd4 = Rd3 * Rd;
114 double Rd5 = Rd4 * Rd;
115 double Rd6 = Rd5 * Rd;
119 Rd6 *
p_odk[3] - Ru * (1.0 / Rd);
121 double fRd2 = 2 *
p_odk[1] * Rd +
133 dxPix = uxPix * (Rd / Ru);
134 dyPix = uyPix * (Rd / Ru);
142 double MarciDistortionMap::GuessDx(
double uX) {
144 if(fabs(uX) < 1)
return uX;
147 return (1.4101 * log(fabs(uX)));
150 else if(p_filter == 1) {
151 return (1.1039 * log(fabs(uX)));
154 else if(p_filter == 2) {
155 return (0.8963 * log(fabs(uX)) + 2.1644);
158 else if(p_filter == 3) {
159 return (1.1039 * log(fabs(uX)));
162 else if(p_filter == 4) {
163 return (1.4101 * log(fabs(uX)));
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 bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane x/y.
MarciDistortionMap(Camera *parent, int naifIkCode)
Camera distortion map constructor.
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane x/y.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.