Isis 3 Programmer Reference
GaussianStretch.cpp
Go to the documentation of this file.
1 
23 #include "GaussianStretch.h"
24 #include "GaussianDistribution.h"
25 #include "Stretch.h"
26 #include "Message.h"
27 #include <string>
28 #include <iostream>
29 #include <iomanip>
30 
31 using namespace std;
32 namespace Isis {
41  GaussianStretch::GaussianStretch(Histogram &histogram, const double mean, const double standardDeviation) {
42  GaussianDistribution dis(mean, standardDeviation);
43 
44  p_stretch.ClearPairs();
45  p_stretch.AddPair(histogram.Minimum(), histogram.Minimum());
46  double lastvalue = histogram.Minimum();
47  for(int i = 1; i <= histogram.Bins() - 1; i++) {
48  double percent = 100.0 * (double)i / (double)histogram.Bins();
49  double input = histogram.Percent(percent);
50  // stretch pairs must be monotonically increasing
51  if(lastvalue + DBL_EPSILON > input) continue;
52  if(fabs(input - lastvalue) < 100.0 * DBL_EPSILON) continue;
53  double output = dis.InverseCumulativeDistribution(percent);
54  p_stretch.AddPair(input, output);
55  lastvalue = input;
56  }
57 
58  if(histogram.Maximum() > lastvalue) {
59  if(abs(histogram.Maximum() - lastvalue) > 100 * DBL_EPSILON) {
60  p_stretch.AddPair(histogram.Maximum(), histogram.Maximum());
61  }
62  }
63  }
64 
73  double GaussianStretch::Map(const double value) const {
74  return p_stretch.Map(value);
75  }
76 }
gaussian distribution class
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
Definition: Statistics.cpp:395
Namespace for the standard library.
double InverseCumulativeDistribution(const double percent)
Computes and returns the inverse cumulative distribution evaluated at the specified percentage valu...
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
Definition: Statistics.cpp:416
Container of a cube histogram.
Definition: Histogram.h:86
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
Definition: Histogram.cpp:572
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
int Bins() const
Returns the number of bins in the histogram.
Definition: Histogram.cpp:704