Isis 3 Programmer Reference
GradientOperator.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "GradientOperator.h"
8#include "Chip.h"
9
10namespace 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
47extern "C" Isis::InterestOperator *GradientOperatorPlugin(Isis::Pvl &pPvl) {
48 return new Isis::GradientOperator(pPvl);
49}
50
A small chip of data used for pattern matching.
Definition Chip.h:86
double GetValue(int sample, int line)
Loads a Chip with a value.
Definition Chip.h:145
int Samples() const
Definition Chip.h:99
int Lines() const
Definition Chip.h:106
bool ValidDnValue(double pdDnValue)
Validate whether the DN Value is in the set Range.
Gradient interest operator.
virtual double Interest(Chip &chip)
This method returns the amount of interest for the given chip.
Interest Operator class.
Container for cube-like labels.
Definition Pvl.h:119
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16