Isis 3 Programmer Reference
MinimumDifference.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "MinimumDifference.h"
9 #include "Chip.h"
10 
11 namespace Isis {
12 
31  double MinimumDifference::MatchAlgorithm(Chip &pattern, Chip &subsearch) {
32  // calculate the sampling information
33 
34  double diff = 0.0;
35  double count = 0;
36  for(double l = 1.0; l <= pattern.Lines(); l++) {
37  for(double s = 1.0; s <= pattern.Samples(); s++) {
38  int line = (int)l;
39  int samp = (int)s;
40 
41  double pdn = pattern.GetValue(samp, line);
42  double sdn = subsearch.GetValue(samp, line);
43  if(IsSpecial(pdn)) continue;
44  if(IsSpecial(sdn)) continue;
45  diff += fabs(pdn - sdn);
46  count++;
47  }
48  }
49 
50  return diff / count;
51  }
52 
60  bool MinimumDifference::CompareFits(double fit1, double fit2) {
61  return (fit1 <= fit2);
62  }
63 }
64 
65 extern "C" Isis::AutoReg *MinimumDifferencePlugin(Isis::Pvl &pvl) {
66  return new Isis::MinimumDifference(pvl);
67 }
68 
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::MinimumDifference::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: MinimumDifference.cpp:60
Isis::MinimumDifference::MatchAlgorithm
virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch)
Minimum difference match algorithm.
Definition: MinimumDifference.cpp:31
Isis::IsSpecial
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:197
Isis::AutoReg
Auto Registration class.
Definition: AutoReg.h:167
Isis::Chip::Lines
int Lines() const
Definition: Chip.h:106
Isis::MinimumDifference
Minimum difference pattern matching.
Definition: MinimumDifference.h:41
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