Isis 3 Programmer Reference
GaussianStretch.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "GaussianStretch.h"
8 #include "GaussianDistribution.h"
9 #include "Stretch.h"
10 #include "Message.h"
11 #include <string>
12 #include <iostream>
13 #include <iomanip>
14 
15 using namespace std;
16 namespace Isis {
25  GaussianStretch::GaussianStretch(Histogram &histogram, const double mean, const double standardDeviation) {
26  GaussianDistribution dis(mean, standardDeviation);
27 
28  p_stretch.ClearPairs();
29  p_stretch.AddPair(histogram.Minimum(), histogram.Minimum());
30  double lastvalue = histogram.Minimum();
31  for(int i = 1; i <= histogram.Bins() - 1; i++) {
32  double percent = 100.0 * (double)i / (double)histogram.Bins();
33  double input = histogram.Percent(percent);
34  // stretch pairs must be monotonically increasing
35  if(lastvalue + DBL_EPSILON > input) continue;
36  if(fabs(input - lastvalue) < 100.0 * DBL_EPSILON) continue;
37  double output = dis.InverseCumulativeDistribution(percent);
38  p_stretch.AddPair(input, output);
39  lastvalue = input;
40  }
41 
42  if(histogram.Maximum() > lastvalue) {
43  if(abs(histogram.Maximum() - lastvalue) > 100 * DBL_EPSILON) {
44  p_stretch.AddPair(histogram.Maximum(), histogram.Maximum());
45  }
46  }
47  }
48 
57  double GaussianStretch::Map(const double value) const {
58  return p_stretch.Map(value);
59  }
60 }
Isis::Histogram::Percent
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
Definition: Histogram.cpp:351
Isis::Statistics::Maximum
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
Definition: Statistics.cpp:403
Isis::Statistics::Minimum
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
Definition: Statistics.cpp:382
Isis::GaussianDistribution
gaussian distribution class
Definition: GaussianDistribution.h:37
Isis::Histogram::Bins
int Bins() const
Returns the number of bins in the histogram.
Definition: Histogram.cpp:483
std
Namespace for the standard library.
Isis::Histogram
Container of a cube histogram.
Definition: Histogram.h:74
Isis::GaussianDistribution::InverseCumulativeDistribution
double InverseCumulativeDistribution(const double percent)
Computes and returns the inverse cumulative distribution evaluated at the specified percentage value ...
Definition: GaussianDistribution.cpp:90
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16