9#include "ControlMeasure.h"
10#include "ControlNet.h"
11#include "ControlPoint.h"
12#include "LineManager.h"
14#include "SpecialPixel.h"
33 Histogram::Histogram(
double minimum,
double maximum,
int nbins) {
53 string msg =
"The number of Histogram Bins must be greater than 0";
79 string msg =
"The width of Histogram Bins must be greater than 0";
90 double domain = this->ValidMaximum() - this->ValidMinimum();
91 int nBins = int ( ceil(domain/binWidth) ) - 1;
109 int nObjPts = net.GetNumPoints();
110 for (
int i=0; i<nObjPts; i++) {
112 if (point->IsIgnored() )
continue;
115 int nObs = point->GetNumMeasures();
116 for (
int j=0; j<nObs; j++) {
120 if (measure->IsIgnored())
continue;
121 this->
AddData((measure->*statFunc)());
141 int nObjPts = net.GetNumPoints();
142 for (
int i=0; i<nObjPts; i++) {
145 if (point->IsIgnored())
continue;
148 int nObs = point->GetNumMeasures();
150 for (
int j=0; j<nObs; j++) {
153 if (measure->IsIgnored())
continue;
155 temp = (measure->*statFunc)();
156 if ( !
IsSpecial(temp) && temp > max ) max = temp;
157 if ( !
IsSpecial(temp) && temp < min ) min = temp;
163 string msg =
"The net file appears to have 1 or fewer measures with residual data, "
164 "thus no histogram for this net file can be created;";
193 if (binEnd < binStart) {
194 string msg =
"The binning range start [" +
IString(binStart) +
"]"
195 " must be less than the end [" +
IString(binEnd) +
"].";
203 Isis::Statistics::SetValidRange(binStart,binEnd);
204 p_binRangeStart = binStart;
205 p_binRangeEnd = binEnd;
212 for (
int i = 0; i < (int)
p_bins.size(); i++) {
233 const unsigned int count) {
236 int nbins =
p_bins.size();
238 for (
unsigned int i = 0; i < count; i++) {
240 if (BinRangeStart() == BinRangeEnd() ) {
244 index = (int) floor( ((
double) nbins / (BinRangeEnd() - BinRangeStart())) *
245 (data[i] - BinRangeStart()) );
247 if (index < 0) index = 0;
248 if (index >= nbins) index = nbins - 1;
265 int nbins =
p_bins.size();
268 if (BinRangeStart() == BinRangeEnd() ) {
272 index = (int) floor( ((
double) nbins / (BinRangeEnd() - BinRangeStart())) *
273 (data - BinRangeStart()) );
275 if (index < 0) index = 0;
276 if (index >= nbins) index = nbins - 1;
292 const unsigned int count) {
295 int nbins =
p_bins.size();
297 for (
unsigned int i = 0; i < count; i++) {
300 if (BinRangeStart() == BinRangeEnd() ) {
304 index = (int) floor( ((
double) nbins / (BinRangeEnd() - BinRangeStart())) *
305 (data[i] - BinRangeStart()) );
307 if (index < 0) index = 0;
308 if (index >= nbins) index = nbins - 1;
330 for (
int i = 0; i < (int)
p_bins.size(); i++) {
335 if (
p_bins[mode] < 1)
return NULL8;
352 if ( (percent < 0.0) || (percent > 100.0) ) {
353 string m =
"Argument percent outside of the range 0 to 100 in";
354 m +=
" [Histogram::Percent]";
361 double currentPercent;
363 for (
int i = 0; i < (int)
p_bins.size(); i++) {
365 currentPixels +=
p_bins[i];
366 currentPercent = (double) currentPixels / (
double)
ValidPixels() * 100.0;
368 if (currentPercent >= percent) {
390 if (sdev == 0.0)
return 0.0;
405 if ( (index < 0) || (index >= (
int)
p_bins.size() ) ) {
428 double &low,
double &high)
const {
429 if ( (index < 0) || (index >= (
int)
p_bins.size() ) ) {
435 double binSize = (BinRangeEnd() - BinRangeStart()) / (
double)
p_bins.size();
436 low = BinRangeStart() + binSize * (double) index;
437 high = low + binSize;
450 if ( (index < 0) || (index >= (
int)
p_bins.size() ) ) {
459 return (low + high) / 2.0;
484 return (
int)
p_bins.size();
496 for (
int i = 0; i < (int)
p_bins.size(); i++) {
const ControlMeasure * GetMeasure(QString serialNumber) const
Get a control measure based on its cube's serial number.
void SetBins(const int bins)
Change the number of bins in the histogram and reset counters.
double BinSize() const
Returns the size of an individual bin.
BigInt BinCount(const int index) const
Returns the count at a bin position in the histogram.
std::vector< BigInt > p_bins
The array of counts.
void addMeasureDataFromNet(ControlNet &net, double(ControlMeasure::*statFunc)() const)
Iterates through all the measures in a network adding them to the histogram.
double BinMiddle(const int index) const
Returns the value represented by a bin.
void SetValidRange(const double minimum=Isis::ValidMinimum, const double maximum=Isis::ValidMaximum)
Changes the range of the bins.
double Median() const
Returns the median.
int Bins() const
Returns the number of bins in the histogram.
virtual void RemoveData(const double *data, const unsigned int count)
Remove an array of doubles from the histogram counters.
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
double Mode() const
Returns the mode.
BigInt MaxBinCount() const
Returns the highest bin count.
~Histogram()
Destructs a histogram object.
virtual void AddData(const double *data, const unsigned int count)
Add an array of doubles to the histogram counters.
void Reset()
Resets histogram counters to zero.
double Skew() const
Computes and returns the skew.
void rangesFromNet(ControlNet &net, double(ControlMeasure::*statFunc)() const)
Iterates through all the measures in a network in order to find the domain of the data.
virtual void BinRange(const int index, double &low, double &high) const
Returns the left edge and right edge values of a bin.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
@ Programmer
This error is for when a programmer made an API call that was illegal.
Adds specific functionality to C++ strings.
double Average() const
Computes and returns the average.
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
void RemoveData(const double *data, const unsigned int count)
Remove an array of doubles from the accumulators and counters.
double StandardDeviation() const
Computes and returns the standard deviation.
void Reset()
Reset all accumulators and counters to zero.
QString ArraySubscriptNotInRange(int index)
This error should be used when an Isis object or application is checking array bounds and the legal r...
This is free and unencumbered software released into the public domain.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
long long int BigInt
Big int.
bool IsSpecial(const double d)
Returns if the input pixel is special.
Namespace for the standard library.