15#include <tnt/tnt_array1d.h> 
   16#include <tnt/tnt_array2d.h> 
   17#include <tnt/tnt_array2d_utils.h> 
   22#include "IException.h" 
   23#include "PvlKeyword.h" 
   24#include "SpecialPixel.h" 
   30 typedef TNT::Array1D<double> GVector;
 
   56      Coordinate(
double y, 
double x) : m_y(y), m_x(x) { }
 
   62      void setLatLon(
const double &latitude, 
const double &longitude) {
 
 
   77        if ( 
isValid() && other.isValid()) {
 
 
   89        if ( 
isValid() && other.isValid() ) {
 
 
  101        double yd = pntA.m_y - m_y;
 
  102        double xd = pntA.m_x - m_x;
 
  103        return (std::sqrt((xd * xd) + (yd * yd)));
 
 
  111      inline double getLatitude()
 const { 
return (m_y); }
 
  112      inline double getLongitude()
 const { 
return (m_x); }
 
  113      inline double getLine()
 const { 
return (m_y); }
 
  114      inline double getSample()
 const { 
return (m_x); }
 
 
  132      return (
Coordinate(A.m_y+B.m_y, A.m_x+B.m_x));
 
 
  150      return (
Coordinate(A.m_y-B.m_y, A.m_x-B.m_x));
 
 
  174      PointPair(
const double &line, 
const double &sample) : m_left(line, sample),
 
  184      inline const Coordinate &getLeft()
  const { 
return (m_left);  }
 
  185      inline const Coordinate &getRight()
 const { 
return (m_right); }
 
  187      inline double getLine()
 const { 
return (getLeftLine()); }
 
  188      inline double getSample()
 const { 
return (getLeftSample()); }
 
  189      inline double getLeftLine()
 const { 
return (m_left.getLine()); }
 
  190      inline double getLeftSample()
 const { 
return (m_left.getSample()); }
 
  191      inline double getRightLine()
 const { 
return (m_right.getLine()); }
 
  192      inline double getRightSample()
 const { 
return (m_right.getSample()); }
 
 
  209      Radiometric(
const double &shift, 
const double &gain) :
 
  210                       m_shift(shift), m_gain(gain) { }
 
  212      inline double Shift()
 const { 
return (m_shift);  }
 
  213      inline double Gain()
  const { 
return (m_gain);   }
 
  218        m_shift += B.m_shift;
 
 
 
  229    return (
Radiometric(A.m_shift+B.m_shift, A.m_gain+B.m_gain));
 
 
  245      AffineRadio(
const GMatrix &A) : m_affine(A), m_radio() { }
 
  247                  const double &gain) : m_affine(M), m_radio(shift, gain) { }
 
  248      AffineRadio(
const GVector &alpha) : m_affine(), m_radio() {
 
  258        m_radio += other.m_radio;
 
 
  265        trans[0][2] = offset.getSample();
 
  266        trans[1][2] = offset.getLine();
 
  267        m_affine = TNT::matmult(trans, m_affine);
 
 
  273        double x = m_affine[0][0] * location.getSample() +
 
  274                   m_affine[0][1] * location.getLine()   + m_affine[0][2];
 
  275        double y = m_affine[1][0] * location.getSample() +
 
  276                   m_affine[1][1] * location.getLine()   + m_affine[1][2];
 
 
  286        if ( alpha.dim1() != 8 ) {
 
  287          QString mess = 
"Alpha array for AffineRadio must have 8 elements " 
  288                             " but has " + 
toString(alpha.dim1());
 
  292        m_affine[0][0] += alpha[1];
 
  293        m_affine[0][1] += alpha[2];
 
  294        m_affine[0][2] += alpha[0];
 
  296        m_affine[1][0] += alpha[4];
 
  297        m_affine[1][1] += alpha[5];
 
  298        m_affine[1][2] += alpha[3];
 
  300        m_radio.m_shift = alpha[6];
 
  301        m_radio.m_gain  = alpha[7];
 
 
 
  321      AffineTolerance() : m_transTol(0.1), m_scaleTol(0.5), m_shearTol(0.5) { }
 
  323                      const double &shearTol) : m_transTol(transTol),
 
  324                                          m_scaleTol(scaleTol),
 
  325                                          m_shearTol(shearTol) { }
 
 
  352        m_thresh[0] = tolerance.m_scaleTol / (((double)(chip.
Samples() - 1)) / 2.0);
 
  353        m_thresh[1] = tolerance.m_shearTol / (((double)(chip.
Lines() - 1)) / 2.0);
 
  354        m_thresh[2] = tolerance.m_transTol;
 
  356        m_thresh[3] = tolerance.m_shearTol / (((double)(chip.
Samples() - 1)) / 2.0);
 
  357        m_thresh[4] = tolerance.m_scaleTol / (((double)(chip.
Lines() - 1)) / 2.0);
 
  358        m_thresh[5] = tolerance.m_transTol;
 
  365        const double *alpha = Malpha[0];
 
  366        for ( 
int i = 0 ; i < m_thresh.dim1() ; i++ ) {
 
  367          if ( std::fabs(alpha[i]) >= m_thresh[i] ) 
return (
false);
 
 
 
  384    Analysis() : m_npts(0), m_variance(0.0), m_sevals(),
 
  385                 m_kmat(), m_status(-1) {
 
  386      for ( 
int i = 0 ; i < 2 ; i++ ) {
 
  393    inline bool isValid()
 const { 
return (m_status == 0); }
 
  397      double eigen = std::sqrt(m_sevals[0] * m_sevals[0] +
 
  398                               m_sevals[1] * m_sevals[1]);
 
 
  404      for ( 
int i = 0 ; i < 2 ; i++ ) {
 
 
 
  435      MatchPoint() : m_point(), m_affine(), m_analysis(), m_status(-1) { }
 
  437                                             m_analysis(), m_status(-1) { }
 
  439                                           m_analysis(), m_status(-1) { }
 
  442      inline int getStatus()
 const { 
return (m_status);  }
 
  448      inline bool isValid()
 const {  
return (m_status == 0); }
 
  449      inline double getEigen()
 const { 
return (m_analysis.
getEigen()); }
 
 
static AMatrix getIdentity()
Return an Affine identity matrix.
 
TNT::Array2D< double > AMatrix
Affine Matrix.
 
Container for affine and radiometric parameters.
 
void clone(const GVector &alpha)
Generate a matrix from the Gruen alpha vector.
 
Coordinate getPoint(const Coordinate &location) const
Applies the affine transfrom to a point and returns result.
 
AffineRadio & operator+=(const AffineRadio &other)
Define update procedure for accumulating Gruen iterations.
 
void Translate(const Coordinate &offset)
Apply a translation to the given offset.
 
A small chip of data used for pattern matching.
 
double CubeSample() const
 
Define a generic Y/X container.
 
Coordinate & operator-=(const Coordinate &other)
Subtract a point from this point.
 
bool isValid() const
Check for goodness.
 
void setLatLon(const double &latitude, const double &longitude)
Use Latitude/Longitude interface.
 
Coordinate & operator+=(const Coordinate &other)
Add a point to this point.
 
void setLineSamp(const double &line, const double &sample)
Use the Line/Sample interface.
 
double getDistance(const Coordinate &pntA=Coordinate(0.0, 0.0)) const
Computes the distance from this point and the point provided.
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
Structure containing comprehensive registration info/results.
 
Coordinate getAffinePoint(const Coordinate &coord=Coordinate(0.0, 0.0)) const
Return registration offset of a given chip coordinate from center
 
Define a point set of left, right and geometry at that location.
 
bool isValid() const
Left, right and geometry coordinates must all be good data.
 
Store for radiometric gain and shift parameters.
 
Radiometric & operator+=(const Radiometric &B)
Add radiometric parameters from another set of parameters.
 
Compute/test the Affine convergence from given parameters/chip.
 
bool hasConverged(const AffineRadio &affine) const
Determines convergence from an affine/radiometric fit.
 
This is free and unencumbered software released into the public domain.
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
 
const double Null
Value for an Isis Null pixel.
 
long long int BigInt
Big int.
 
Coordinate operator+(const Coordinate &A, const Coordinate &B)
Summation operator for Coordinate.
 
bool IsSpecial(const double d)
Returns if the input pixel is special.
 
Coordinate operator-(const Coordinate &A, const Coordinate &B)
Subtraction operator for Coordinate.
 
Container for Affine limits parameters.
 
Error analysis of Gruen match point solution.
 
void setZeroState()
Resets eigenvalues to 0.
 
double getEigen() const
Returns the square of the of sum of the squares of eigenvalues.