Isis 3 Programmer Reference
MaximumCorrelation.cpp
1 #include "MaximumCorrelation.h"
2 #include "Chip.h"
4 
5 namespace Isis {
6  double MaximumCorrelation::MatchAlgorithm(Chip &pattern, Chip &subsearch) {
8  std::vector <double> pdn, sdn;
9  pdn.resize(pattern.Samples());
10  sdn.resize(pattern.Samples());
11 
12  for(int l = 1; l <= pattern.Lines(); l++) {
13  for(int s = 1; s <= pattern.Samples(); s++) {
14  pdn[s-1] = pattern.GetValue(s, l);
15  sdn[s-1] = subsearch.GetValue(s, l);
16  }
17  mv.AddData(&pdn[0], &sdn[0], pattern.Samples());
18  }
19  double percentValid = (double) mv.ValidPixels() /
20  (pattern.Lines() * pattern.Samples());
21  if(percentValid * 100.0 < this->PatternValidPercent()) return Isis::Null;
22 
23  double r = mv.Correlation();
24  if(r == Isis::Null) return Isis::Null;
25  return fabs(r);
26  }
27 
35  bool MaximumCorrelation::CompareFits(double fit1, double fit2) {
36  return (fit1 >= fit2);
37  }
38 }
39 
40 extern "C" Isis::AutoReg *MaximumCorrelationPlugin(Isis::Pvl &pvl) {
41  return new Isis::MaximumCorrelation(pvl);
42 }
43 
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:110
virtual bool CompareFits(double fit1, double fit2)
This virtual method must return if the 1st fit is equal to or better than the second fit...
A small chip of data used for pattern matching.
Definition: Chip.h:102
BigInt ValidPixels() const
Returns the number of valid pixels processed.
virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch)
Given two identically sized chips return a double that indicates how well they match.
double Correlation() const
Computes and returns the coefficient of correlation (between -1.0 and 1.0) of the two data sets...
int Lines() const
Definition: Chip.h:122
Container of multivariate statistics.
double PatternValidPercent() const
Return pattern chip valid percent. The default value is.
Definition: AutoReg.h:296
Container for cube-like labels.
Definition: Pvl.h:135
Auto Registration class.
Definition: AutoReg.h:183
int Samples() const
Definition: Chip.h:115
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void AddData(const double *x, const double *y, const unsigned int count)
Add two arrays of doubles to the accumulators and counters.
double GetValue(int sample, int line)
Loads a Chip with a value.
Definition: Chip.h:161
Maximum correlation pattern matching.