44 ReseauDistortionMap::ReseauDistortionMap(
Camera *parent,
Pvl &labels,
const QString &fname) :
49 p_distortedLines = dim.
findKeyword(
"DistortedLines");
51 p_undistortedLines = dim.
findKeyword(
"UndistortedLines");
58 string msg =
"The number of lines and samples for the master reseaus are";
59 msg +=
"not equal, the data file may be bad";
63 p_mlines.push_back(
toDouble(mline[i]));
72 string msg =
"The number of lines and samples for the refined reseaus are";
73 msg +=
"not equal, the data file may be bad";
77 p_rlines.push_back(
toDouble(rline[i]));
80 if(p_mlines.size() != p_rlines.size()) {
81 string msg =
"The number of master reseaus and refined reseaus";
82 msg +=
"do not appear to be equal";
110 double ldiffsq, sdiffsq;
113 ldiffsq = (focalLine - p_rlines[i]) * (focalLine - p_rlines[i]);
114 distances[i] = ldiffsq + sdiffsq;
118 for(
int ifpt = 0; ifpt < 5; ifpt++) {
121 if(distances[i] < distances[imin]) imin = i;
123 closepts[ifpt] = imin;
124 wt[ifpt] = distances[imin];
125 distances[imin] = DBL_MAX;
130 double line[5], samp[5];
131 for(
int k = 0; k < 5; k++) {
132 line[k] = p_rlines[closepts[k]];
145 double scale = wt[0];
146 double rfitlines[5], rfitsamps[5], mfitlines[5], mfitsamps[5];
147 for(
int ifpt = 0; ifpt < 5; ifpt++) {
148 int index = closepts[ifpt];
149 rfitlines[ifpt] = p_rlines[index];
151 mfitlines[ifpt] = p_mlines[index];
153 wt[ifpt] = scale / wt[ifpt];
160 vector<double> known;
162 for(
int i = 0; i < 5; i++) {
164 known[1] = rfitsamps[i];
165 known[2] = rfitlines[i];
166 lsqX.
AddKnown(known, mfitsamps[i], wt[i]);
167 lsqY.
AddKnown(known, mfitlines[i], wt[i]);
172 known[1] = focalSamp;
173 known[2] = focalLine;
176 double undistortedFocalSamp = lsqX.
Evaluate(known);
177 double undistortedFocalLine = lsqY.
Evaluate(known);
178 if(undistortedFocalSamp < 0.5)
return false;
179 if(undistortedFocalLine < 0.5)
return false;
181 if(undistortedFocalLine > p_undistortedLines + 0.5)
return false;
186 p_undistortedFocalPlaneY = (undistortedFocalLine - p_undistortedLines
190 int index = closepts[0];
193 p_undistortedFocalPlaneY = (p_mlines[index] - p_undistortedLines / 2.0)
210 p_undistortedFocalPlaneX = ux;
211 p_undistortedFocalPlaneY = uy;
215 double undistortedFocalLine = uy /
p_pixelPitch + p_undistortedLines / 2.0;
220 double ldiffsq, sdiffsq;
222 sdiffsq = (undistortedFocalSamp -
p_msamps[i]) *
223 (undistortedFocalSamp -
p_msamps[i]);
224 ldiffsq = (undistortedFocalLine - p_mlines[i]) *
225 (undistortedFocalLine - p_mlines[i]);
226 distances[i] = ldiffsq + sdiffsq;
230 for(
int ifpt = 0; ifpt < 5; ifpt++) {
233 if(distances[i] < distances[imin]) imin = i;
235 closepts[ifpt] = imin;
236 wt[ifpt] = distances[imin];
237 distances[imin] = DBL_MAX;
242 double line[5], samp[5];
243 for(
int k = 0; k < 5; k++) {
244 line[k] = p_rlines[closepts[k]];
256 double scale = wt[0];
257 double rfitlines[5], rfitsamps[5], mfitlines[5], mfitsamps[5];
258 for(
int ifpt = 0; ifpt < 5; ifpt++) {
259 int index = closepts[ifpt];
260 mfitlines[ifpt] = p_mlines[index];
262 rfitlines[ifpt] = p_rlines[index];
264 wt[ifpt] = scale / wt[ifpt];
271 vector<double> known;
273 for(
int i = 0; i < 5; i++) {
275 known[1] = mfitsamps[i];
276 known[2] = mfitlines[i];
277 lsqX.
AddKnown(known, rfitsamps[i], wt[i]);
278 lsqY.
AddKnown(known, rfitlines[i], wt[i]);
283 known[1] = undistortedFocalSamp;
284 known[2] = undistortedFocalLine;
287 double distortedFocalSamp = lsqX.
Evaluate(known);
288 double distortedFocalLine = lsqY.
Evaluate(known);
289 if(distortedFocalSamp < 0.5)
return false;
290 if(distortedFocalLine < 0.5)
return false;
292 if(distortedFocalLine > p_undistortedLines + 0.5)
return false;
295 p_focalPlaneX = (distortedFocalSamp -
297 p_focalPlaneY = (distortedFocalLine -
302 int index = closepts[0];
305 p_focalPlaneY = (p_rlines[index] -
int size() const
Returns the number of values stored in this keyword.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
double p_undistortedSamps
Dimensions of undistorted cube.
double p_pixelPitch
Pixel Pitch of parent Camera.
double toDouble(const QString &string)
Global function to convert from a string to a double.
std::vector< double > p_rsamps
Refined Reseau Locations.
double StandardDeviation() const
Computes and returns the standard deviation.
This class is used to accumulate statistics on double arrays.
double DetectorSampleOrigin() const
Return detector sample origin.
double Evaluate(const std::vector< double > &input)
Invokes the BasisFunction Evaluate method.
std::vector< double > p_msamps
Master Reseau Locations.
double p_distortedSamps
Dimensions of distorted cube.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
A type of error that could only have occurred due to a mistake on the user's part (e...
A single keyword-value pair.
Distort/undistort focal plane coordinates.
Generic least square fitting class.
Container for cube-like labels.
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Finds the distorted x/y position of the given undistorted point.
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
int p_numRes
Number of Reseaus.
void AddKnown(const std::vector< double > &input, double expected, double weight=1.0)
Invoke this method for each set of knowns.
virtual bool SetFocalPlane(const double dx, const double dy)
Finds the undistorted x/y position of the given distorted point.
double PixelPitch() const
Returns the pixel pitch.
Generic linear equation class.
double DetectorLineOrigin() const
Return detector line origin.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
int Solve(Isis::LeastSquares::SolveMethod method=SVD)
After all the data has been registered through AddKnown, invoke this method to solve the system of eq...