Isis 3 Programmer Reference
GradientOperator.cpp
1 #include "GradientOperator.h"
2 #include "Chip.h"
3 
4 namespace Isis {
13  double gradient = 0.0;
14  double pix1, pix2;
15  int height = chip.Lines();
16  int width = chip.Samples();
17  int offset = 0;
18 
19  while(width > 1 && height > 1) {
20  for(int i = 1; i <= width; i++) {
21  pix1 = chip.GetValue(i + offset, 1 + offset);
22  pix2 = chip.GetValue(width - i + 1 + offset, height + offset);
23  if(ValidDnValue(pix1) && ValidDnValue(pix2)) gradient += std::abs(pix1 - pix2);
24  }
25 
26  for(int i = 2; i < height; i++) {
27  pix1 = chip.GetValue(1 + offset, i + offset);
28  pix2 = chip.GetValue(width + offset, height - i + 1 + offset);
29  if(ValidDnValue(pix1) && ValidDnValue(pix2)) gradient += std::abs(pix1 - pix2);
30  }
31 
32  width -= 2;
33  height -= 2;
34  offset += 1;
35  }
36 
37  return gradient;
38  }
39 }
40 
41 extern "C" Isis::InterestOperator *GradientOperatorPlugin(Isis::Pvl &pPvl) {
42  return new Isis::GradientOperator(pPvl);
43 }
44 
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.
virtual double Interest(Chip &chip)
This method returns the amount of interest for the given chip.
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
double GetValue(int sample, int line)
Loads a Chip with a value.
Definition: Chip.h:161
Gradient interest operator.