Isis 3 Programmer Reference
MoravecOperator.cpp
1 #include "MoravecOperator.h"
2 #include "Chip.h"
3 
4 namespace Isis {
13  int height = chip.Lines();
14  int width = chip.Samples();
15  std::vector<double> interests;
16  double smallestInterest = 0.0;
17 
18  // Create offsets for comparison of different areas of the chip
19  for(int offX = -1; offX <= 1; offX++) {
20  for(int offY = -1; offY <= 1; offY++) {
21  // doesnt do work if offset would be center chip
22  if(offX == 0 && offY == 0) continue;
23  // Do interest computation between center and offset areas and store into array
24  double interest = 0.0;
25  for(int y = 2; y <= height - 1; y++) {
26  for(int x = 2; x <= width - 1; x++) {
27  // If either pixel is special ignore difference
28  if(ValidDnValue(chip.GetValue(x, y)) && ValidDnValue(chip.GetValue(x + offX, y + offY))) {
29  interest += std::pow(chip.GetValue(x, y) - chip.GetValue(x + offX, y + offY), 2);
30  }
31  }
32  }
33  // Initialize smallest interest with first value
34  if(interests.size() == 1) {
35  smallestInterest = interest;
36  }
37  interests.push_back(interest);
38  }
39  }
40  // find smallest interest and return
41  for(unsigned int i = 0; i < interests.size(); i++) {
42  if(interests[i] < smallestInterest) {
43  smallestInterest = interests[i];
44  }
45  }
46  return smallestInterest;
47  }
48 
56  return 2;
57  }
58 }
59 extern "C" Isis::InterestOperator *MoravecOperatorPlugin(Isis::Pvl &pPvl) {
60  return new Isis::MoravecOperator(pPvl);
61 }
A small chip of data used for pattern matching.
Definition: Chip.h:102
Interest Operator class.
bool ValidDnValue(double pdDnValue)
Validate whether the DN Value is in the set Range.
Moravec Interest Operator.
int Lines() const
Definition: Chip.h:122
Container for cube-like labels.
Definition: Pvl.h:135
int Samples() const
Definition: Chip.h:115
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual int Padding()
Sets an offset to pass in larger chips if operator requires it This is used to offset the subchip siz...
double GetValue(int sample, int line)
Loads a Chip with a value.
Definition: Chip.h:161
virtual double Interest(Chip &chip)
This method returns the amount of interest for the given chip.