12#include <boost/math/special_functions/legendre.hpp>
16#include "FunctionTools.h"
18#include "NewHorizonsMvicFrameCameraDistortionMap.h"
20#include "CameraFocalPlaneMap.h"
26using namespace boost::math;
44 vector<double> xDistortionCoeffs,
45 vector<double> yDistortionCoeffs) :
137 double yscaled = -dy/m_focalPlaneHalf_y;
143 double deltax, deltay;
214 double xScaledDistortion, yScaledDistortion;
218 double ytScaled = -uy/m_focalPlaneHalf_y;
220 double uxScaled = xtScaled;
221 double uyScaled = ytScaled;
223 double xScaledPrevious = 1000000.0;
224 double yScaledPrevious = 1000000.0;
226 double tolerance = 0.000001;
228 bool bConverged =
false;
233 for(
int i = 0; i < 50; i++ ) {
239 xtScaled = uxScaled - xScaledDistortion;
240 ytScaled = uyScaled - yScaledDistortion;
243 if((fabs(xtScaled - xScaledPrevious) <= tolerance) && (fabs(ytScaled - yScaledPrevious) <= tolerance)) {
248 xScaledPrevious = xtScaled;
249 yScaledPrevious = ytScaled;
255 ytScaled *= -m_focalPlaneHalf_y;
337 const double yscaled,
338 double &deltax,
double &deltay) {
340 double lpx0, lpx1, lpx2, lpx3, lpx4, lpx5;
341 double lpy0, lpy1, lpy2, lpy3, lpy4, lpy5;
347 lpx0 = legendre_p(0,xscaled);
348 lpx1 = legendre_p(1,xscaled);
349 lpx2 = legendre_p(2,xscaled);
350 lpx3 = legendre_p(3,xscaled);
351 lpx4 = legendre_p(4,xscaled);
352 lpx5 = legendre_p(5,xscaled);
353 lpy0 = legendre_p(0,yscaled);
354 lpy1 = legendre_p(1,yscaled);
355 lpy2 = legendre_p(2,yscaled);
356 lpy3 = legendre_p(3,yscaled);
357 lpy4 = legendre_p(4,yscaled);
358 lpy5 = legendre_p(5,yscaled);
361 catch (
const std::exception& e) {
Distort/undistort focal plane coordinates.
double p_focalPlaneX
Distorted focal plane x.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Camera * p_camera
The camera to distort/undistort.
double p_focalPlaneY
Distorted focal plane y.
double PixelPitch() const
Returns the pixel pitch.
int Lines() const
Returns the number of lines in the image.
int Samples() const
Returns the number of samples in the image.
std::vector< double > m_xDistortionCoeffs
distortion coefficients in x and y as determined
NewHorizonsMvicFrameCameraDistortionMap(Camera *parent, vector< double > xDistortionCoeffs, vector< double > yDistortionCoeffs)
Camera distortion map constructor.
virtual bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane x/y.
double m_focalPlaneHalf_x
half of focal plane x and y dimensions in mm
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane x/y.
std::vector< double > m_yDistortionCoeffs
by Keith Harrison (Interface Control Document section 10.3.1.2)
~NewHorizonsMvicFrameCameraDistortionMap()
Destructor.
bool computeDistortionCorrections(const double xscaled, const double yscaled, double &deltax, double &deltay)
Compute distortion corrections in x and y direction.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.