45   OverlapNormalization::OverlapNormalization(std::vector<Statistics *> statsList) {
    46     m_gainFunction = NULL;
    48     m_offsetFunction = NULL;
    51     m_statsList = statsList;
    53                                        statsList.size(), statsList.size());
    56                                          statsList.size(), statsList.size());
    59     m_gains.resize(statsList.size());
    60     m_offsets.resize(statsList.size());
    61     for (
unsigned int i = 0; i < statsList.size(); i++) {
    72   OverlapNormalization::~OverlapNormalization() {
    73     if (m_gainFunction != NULL) 
delete m_gainFunction;
    74     if (m_offsetFunction != NULL) 
delete m_offsetFunction;
    75     if (m_gainLsq != NULL) 
delete m_gainLsq;
    76     if (m_offsetLsq != NULL) 
delete m_offsetLsq;
    77     for (
unsigned int i = 0; i < m_statsList.size(); i++) 
delete m_statsList[i];
   107     const Statistics &area1, 
const unsigned index1,
   108     const Statistics &area2, 
const unsigned index2,
   110     if (index1 >= m_statsList.size()) {
   111       string msg = 
"The index 1 is outside the bounds of the list.";
   114     if (index2 >=  m_statsList.size()) {
   115       string msg = 
"The index 2 is outside the bounds of the list.";
   126       string msg = 
"All weights must be positive real numbers.";
   140     if (avg1 == 0 || avg2 == 0) 
return NoContrast;
   142     m_overlapList.push_back(o);
   143     m_deltas.push_back(avg2 - avg1);
   144     m_weights.push_back(weight);
   166     if (m_overlapList.size() == 0) {
   167       string msg = 
"None of the input images overlap";
   174     if (m_overlapList.size() + m_idHoldList.size() < m_statsList.size()) {
   175       string msg = 
"Unable to normalize overlaps. The number of overlaps and "   176                    "holds must be greater than the number of input images";
   180     if ( method == LeastSquares::SPARSE ) {
   185       int sparseMatrixRows = m_overlapList.size() + m_idHoldList.size();
   186       int sparseMatrixCols = m_offsetFunction->Coefficients();
   187       m_offsetLsq = 
new LeastSquares(*m_offsetFunction, 
true, sparseMatrixRows, sparseMatrixCols, 
true);
   188       sparseMatrixCols = m_gainFunction->Coefficients();
   189       m_gainLsq = 
new LeastSquares(*m_gainFunction, 
true, sparseMatrixRows, sparseMatrixCols, 
true);
   190       const std::vector<double> alphaWeight(sparseMatrixCols, 1/1000.0);
   191       m_offsetLsq->SetParameterWeights( alphaWeight );
   192       m_gainLsq->SetParameterWeights( alphaWeight );
   196     if (type != Gains && type != GainsWithoutNormalization) {
   198       for (
int overlap = 0; overlap < (int)m_overlapList.size(); overlap++) {
   199         Overlap curOverlap = m_overlapList[overlap];
   200         int id1 = curOverlap.
index1;
   201         int id2 = curOverlap.
index2;
   203         vector<double> input;
   204         input.resize(m_statsList.size());
   205         for (
int i = 0; i < (int)input.size(); i++) input[i] = 0.0;
   209         m_offsetLsq->AddKnown(input, m_deltas[overlap], m_weights[overlap]);
   213       for (
int h = 0; h < (int)m_idHoldList.size(); h++) {
   214         int hold = m_idHoldList[h];
   216         vector<double> input;
   217         input.resize(m_statsList.size());
   218         for (
int i = 0; i < (int)input.size(); i++) input[i] = 0.0;
   220         m_offsetLsq->AddKnown(input, 0.0, 1e30);
   225       m_offsets.resize(m_statsList.size());
   226       m_offsetLsq->Solve(method);
   227       for (
int i = 0; i < m_offsetFunction->Coefficients(); i++) {
   228         m_offsets[i] = m_offsetFunction->Coefficient(i);
   233     if (type != Offsets) {
   235       for (
int overlap = 0; overlap < (int)m_overlapList.size(); overlap++) {
   236         Overlap curOverlap = m_overlapList[overlap];
   237         int id1 = curOverlap.
index1;
   238         int id2 = curOverlap.
index2;
   240         vector<double> input;
   241         input.resize(m_statsList.size());
   242         for (
int i = 0; i < (int)input.size(); i++) input[i] = 0.0;
   248         if (type != GainsWithoutNormalization) {
   267           m_gainLsq->AddKnown(input, log(tanp), m_weights[overlap]);
   270           m_gainLsq->AddKnown(input, 0.0, 1e10); 
   275       for (
int h = 0; h < (int)m_idHoldList.size(); h++) {
   276         int hold = m_idHoldList[h];
   278         vector<double> input;
   279         input.resize(m_statsList.size());
   280         for (
int i = 0; i < (int)input.size(); i++) input[i] = 0.0;
   282         m_gainLsq->AddKnown(input, 0.0, 1e10);
   287       m_gains.resize(m_statsList.size());
   288       m_gainLsq->Solve(method);
   289       for (
int i = 0; i < m_gainFunction->Coefficients(); i++) {
   290         m_gains[i] = exp(m_gainFunction->Coefficient(i));
   309   double OverlapNormalization::Average(
const unsigned index)
 const {
   310     if (index >= m_statsList.size()) {
   311       string msg = 
"The index was out of bounds for the list of statistics.";
   315     return m_statsList[index]->Average();
   330   double OverlapNormalization::Gain(
const unsigned index)
 const {
   331     if (index >= m_statsList.size()) {
   332       string msg = 
"The index was out of bounds for the list of statistics.";
   336     return m_gains[index];
   351   double OverlapNormalization::Offset(
const unsigned index)
 const {
   352     if (index >= m_statsList.size()) {
   353       string msg = 
"The index was out of bounds for the list of statistics.";
   357     return m_offsets[index];
   374   double OverlapNormalization::Evaluate(
double dn, 
unsigned index)
 const {
   376       string msg = 
"The least squares equation has not been successfully ";
   377       msg += 
"solved yet.";
   382     return (dn - 
Average(index)) * Gain(index) + 
Average(index) + Offset(index);
 int index2
Index corresponding to m_statsList for the second overlapping data set. 
 
double StandardDeviation() const
Computes and returns the standard deviation. 
 
Store statistics pertaining to the overlapping areas and indices (corresponding to the statistics lis...
 
Namespace for the standard library. 
 
Statistics area2
Overlapping area for the second data set. 
 
SolutionType
Enumeration for whether user/programmer wants to calculate new gains, offsets, or both when solving...
 
BigInt ValidPixels() const
Returns the total number of valid pixels processed. 
 
This class is used to accumulate statistics on double arrays. 
 
int index1
Index corresponding to m_statsList for the first overlapping data set. 
 
#define _FILEINFO_
Macro for the filename and line number. 
 
bool IsSpecial(const double d)
Returns if the input pixel is special. 
 
Generic least square fitting class. 
 
AddStatus
The result of the attempt to add overlap data to the list of valid overlaps, where Success is a succe...
 
Generic linear equation class. 
 
Statistics area1
Overlapping area for the first data set. 
 
Namespace for ISIS/Bullet specific routines. 
 
double Average() const
Computes and returns the average. 
 
Functor for reduce using average functionality.