Isis 3 Programmer Reference
GradientOperator.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "GradientOperator.h"
8 #include "Chip.h"
9 
10 namespace Isis {
19  double gradient = 0.0;
20  double pix1, pix2;
21  int height = chip.Lines();
22  int width = chip.Samples();
23  int offset = 0;
24 
25  while(width > 1 && height > 1) {
26  for(int i = 1; i <= width; i++) {
27  pix1 = chip.GetValue(i + offset, 1 + offset);
28  pix2 = chip.GetValue(width - i + 1 + offset, height + offset);
29  if(ValidDnValue(pix1) && ValidDnValue(pix2)) gradient += std::abs(pix1 - pix2);
30  }
31 
32  for(int i = 2; i < height; i++) {
33  pix1 = chip.GetValue(1 + offset, i + offset);
34  pix2 = chip.GetValue(width + offset, height - i + 1 + offset);
35  if(ValidDnValue(pix1) && ValidDnValue(pix2)) gradient += std::abs(pix1 - pix2);
36  }
37 
38  width -= 2;
39  height -= 2;
40  offset += 1;
41  }
42 
43  return gradient;
44  }
45 }
46 
47 extern "C" Isis::InterestOperator *GradientOperatorPlugin(Isis::Pvl &pPvl) {
48  return new Isis::GradientOperator(pPvl);
49 }
50 
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::GradientOperator::Interest
virtual double Interest(Chip &chip)
This method returns the amount of interest for the given chip.
Definition: GradientOperator.cpp:18
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::GradientOperator
Gradient interest operator.
Definition: GradientOperator.h:31
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