Isis 3 Programmer Reference
MoravecOperator.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "MoravecOperator.h"
8 #include "Chip.h"
9 
10 namespace Isis {
19  int height = chip.Lines();
20  int width = chip.Samples();
21  std::vector<double> interests;
22  double smallestInterest = 0.0;
23 
24  // Create offsets for comparison of different areas of the chip
25  for(int offX = -1; offX <= 1; offX++) {
26  for(int offY = -1; offY <= 1; offY++) {
27  // doesnt do work if offset would be center chip
28  if(offX == 0 && offY == 0) continue;
29  // Do interest computation between center and offset areas and store into array
30  double interest = 0.0;
31  for(int y = 2; y <= height - 1; y++) {
32  for(int x = 2; x <= width - 1; x++) {
33  // If either pixel is special ignore difference
34  if(ValidDnValue(chip.GetValue(x, y)) && ValidDnValue(chip.GetValue(x + offX, y + offY))) {
35  interest += std::pow(chip.GetValue(x, y) - chip.GetValue(x + offX, y + offY), 2);
36  }
37  }
38  }
39  // Initialize smallest interest with first value
40  if(interests.size() == 1) {
41  smallestInterest = interest;
42  }
43  interests.push_back(interest);
44  }
45  }
46  // find smallest interest and return
47  for(unsigned int i = 0; i < interests.size(); i++) {
48  if(interests[i] < smallestInterest) {
49  smallestInterest = interests[i];
50  }
51  }
52  return smallestInterest;
53  }
54 
62  return 2;
63  }
64 }
65 extern "C" Isis::InterestOperator *MoravecOperatorPlugin(Isis::Pvl &pPvl) {
66  return new Isis::MoravecOperator(pPvl);
67 }
Isis::MoravecOperator::Interest
virtual double Interest(Chip &chip)
This method returns the amount of interest for the given chip.
Definition: MoravecOperator.cpp:18
Isis::ControlNetValidMeasure::ValidDnValue
bool ValidDnValue(double pdDnValue)
Validate whether the DN Value is in the set Range.
Definition: ControlNetValidMeasure.cpp:701
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::Chip::Lines
int Lines() const
Definition: Chip.h:106
Isis::MoravecOperator::Padding
virtual int Padding()
Sets an offset to pass in larger chips if operator requires it This is used to offset the subchip siz...
Definition: MoravecOperator.cpp:61
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
Isis::InterestOperator
Interest Operator class.
Definition: InterestOperator.h:109
Isis::MoravecOperator
Moravec Interest Operator.
Definition: MoravecOperator.h:45