Isis 3 Programmer Reference
MaximumCorrelation.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "MaximumCorrelation.h"
8 #include "Chip.h"
9 #include "MultivariateStatistics.h"
10 
11 namespace Isis {
12  double MaximumCorrelation::MatchAlgorithm(Chip &pattern, Chip &subsearch) {
14  std::vector <double> pdn, sdn;
15  pdn.resize(pattern.Samples());
16  sdn.resize(pattern.Samples());
17 
18  for(int l = 1; l <= pattern.Lines(); l++) {
19  for(int s = 1; s <= pattern.Samples(); s++) {
20  pdn[s-1] = pattern.GetValue(s, l);
21  sdn[s-1] = subsearch.GetValue(s, l);
22  }
23  mv.AddData(&pdn[0], &sdn[0], pattern.Samples());
24  }
25  double percentValid = (double) mv.ValidPixels() /
26  (pattern.Lines() * pattern.Samples());
27  if(percentValid * 100.0 < this->PatternValidPercent()) return Isis::Null;
28 
29  double r = mv.Correlation();
30  if(r == Isis::Null) return Isis::Null;
31  return fabs(r);
32  }
33 
41  bool MaximumCorrelation::CompareFits(double fit1, double fit2) {
42  return (fit1 >= fit2);
43  }
44 }
45 
46 extern "C" Isis::AutoReg *MaximumCorrelationPlugin(Isis::Pvl &pvl) {
47  return new Isis::MaximumCorrelation(pvl);
48 }
49 
Isis::MaximumCorrelation::CompareFits
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.
Definition: MaximumCorrelation.cpp:41
Isis::MultivariateStatistics::ValidPixels
BigInt ValidPixels() const
Returns the number of valid pixels processed.
Definition: MultivariateStatistics.cpp:201
Isis::Chip::GetValue
double GetValue(int sample, int line)
Loads a Chip with a value.
Definition: Chip.h:145
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::MultivariateStatistics::AddData
void AddData(const double *x, const double *y, const unsigned int count)
Add two arrays of doubles to the accumulators and counters.
Definition: MultivariateStatistics.cpp:66
Isis::AutoReg
Auto Registration class.
Definition: AutoReg.h:167
Isis::MaximumCorrelation::MatchAlgorithm
virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch)
Given two identically sized chips return a double that indicates how well they match.
Definition: MaximumCorrelation.cpp:12
Isis::Chip::Lines
int Lines() const
Definition: Chip.h:106
Isis::MaximumCorrelation
Maximum correlation pattern matching.
Definition: MaximumCorrelation.h:36
Isis::MultivariateStatistics
Container of multivariate statistics.
Definition: MultivariateStatistics.h:54
Isis::AutoReg::PatternValidPercent
double PatternValidPercent() const
Return pattern chip valid percent. The default value is.
Definition: AutoReg.h:280
Isis::Null
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:95
Isis::MultivariateStatistics::Correlation
double Correlation() const
Computes and returns the coefficient of correlation (between -1.0 and 1.0) of the two data sets.
Definition: MultivariateStatistics.cpp:171
Isis::Chip
A small chip of data used for pattern matching.
Definition: Chip.h:86
Isis::Chip::Samples
int Samples() const
Definition: Chip.h:99
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16