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
15using namespace std;
16namespace Isis {
25 GaussianStretch::GaussianStretch(Histogram &histogram, const double mean, const double standardDeviation) {
26 GaussianDistribution dis(mean, standardDeviation);
27
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}
gaussian distribution class
Stretch p_stretch
Value of the mean.
double Map(const double value) const
Maps an input value to an output value based on the gaussian distribution.
GaussianStretch(Histogram &histogram, const double mean=0.0, const double standardDeviation=1.0)
Constructs a gaussian stretch object.
Container of a cube histogram.
Definition Histogram.h:74
int Bins() const
Returns the number of bins in the histogram.
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
Definition Stretch.cpp:48
void ClearPairs()
Clears the stretch pairs.
Definition Stretch.h:170
double Map(const double value) const
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings.
Definition Stretch.cpp:69
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.