50   Histogram::Histogram(
double minimum, 
double maximum, 
int nbins) {
    52     SetValidRange(minimum, maximum);
    79   Histogram::Histogram(
Cube &cube, 
int statsBand, 
Progress *progress,
    80       double startSample, 
double startLine,
    81       double endSample, 
double endLine,
    82       int bins, 
bool addCubeData) {
    84     InitializeFromCube(cube, statsBand, progress, bins, startSample, startLine,
    88       Brick cubeDataBrick((
int)(endSample - startSample + 1),
    92       int startBand = statsBand;
    93       int endBand = statsBand;
   100       if (progress != NULL) {
   101         progress->
SetText(
"Gathering histogram");
   103           (
int)(endLine - startLine + 1) * (
int)(endBand - startBand + 1));
   107       for (
int band = startBand; band <= endBand; band++) {
   108         for (
int line = (
int)startLine; line <= endLine; line++) {
   109           cubeDataBrick.SetBasePosition(qRound(startSample), line, band);
   110           cube.
read(cubeDataBrick);
   111           AddData(cubeDataBrick.DoubleBuffer(), cubeDataBrick.size());
   112           if (progress != NULL) {
   134       string msg = 
"The number of Histogram Bins must be greater than 0";
   140     rangesFromNet(net,statFunc);
   143     addMeasureDataFromNet(net,statFunc);
   160     if (binWidth <= 0 ) {
   161       string msg = 
"The width of Histogram Bins must be greater than 0";
   168    rangesFromNet(net,statFunc);
   187    int nBins = int ( ceil(domain/binWidth) );
   191    addMeasureDataFromNet(net,statFunc);
   207     for (
int i=0; i<nObjPts; i++) { 
   209       if (point->IsIgnored() ) 
continue;  
   212       int nObs = point->GetNumMeasures();
   213       for (
int j=0; j<nObs; j++) {  
   217         if (measure->IsIgnored())  
continue;
   219         this->AddData((measure->*statFunc)());
   240     for (
int i=0; i<nObjPts; i++) { 
   243       if (point->IsIgnored()) 
continue;  
   246       int nObs = point->GetNumMeasures();
   248       for (
int j=0; j<nObs; j++) {  
   251         if (measure->IsIgnored())  
continue;
   253         temp = (measure->*statFunc)();  
   254         if ( !
IsSpecial(temp) && temp > max ) max = temp;
   255         if ( !
IsSpecial(temp) && temp < min ) min = temp;
   261       string msg = 
"The net file appears to have 1 or fewer measures with residual data, "   262                    "thus no histogram for this net file can be created;";
   268     SetValidRange(min, max);
   273   void Histogram::InitializeFromCube(
Cube &cube, 
int statsBand,
   274       Progress *progress, 
int nbins, 
double startSample, 
double startLine,
   275       double endSample, 
double endLine) {
   278     if ( (statsBand < 0) || (statsBand > cube.
bandCount() ) ) {
   279       string msg = 
"Cannot gather histogram for band [" + 
IString(statsBand) +
   286     double minDnValue = 
Null;
   287     double maxDnValue = 
Null;
   298     else if (cube.
pixelType() == UnsignedWord) {
   305     else if (cube.
pixelType() == SignedWord) {
   316     else if (cube.
pixelType() == UnsignedInteger ||
   324       IString msg = 
"Unsupported pixel type";
   325       throw IException(IException::Programmer, msg, 
_FILEINFO_);
   328     if (startSample == 
Null)
   331     if (endSample == 
Null)
   334     if (startLine == 
Null)
   341     if (minDnValue == 
Null || maxDnValue == 
Null) {
   343       Brick cubeDataBrick((
int)(endSample - startSample + 1),
   350       int startBand = statsBand;
   351       int endBand = statsBand;
   353       if (statsBand == 0) {
   358       if (progress != NULL) {
   360         progress->
SetText(
"Computing min/max for histogram");
   362           (
int)(endLine - startLine + 1) * (
int)(endBand - startBand + 1) );
   366       for (
int band = startBand; band <= endBand; band++) {
   367         for (
int line = (
int)startLine; line <= endLine; line++) {
   369           cubeDataBrick.SetBasePosition(qRound(startSample), line, band);
   370           cube.
read(cubeDataBrick);
   371           stats.AddData(cubeDataBrick.DoubleBuffer(), cubeDataBrick.size());
   373           if (progress != NULL) {
   379       if (stats.ValidPixels() == 0) {
   384         minDnValue = stats.Minimum();
   385         maxDnValue = stats.Maximum();
   390     SetValidRange(minDnValue, maxDnValue);
   396   Histogram::~Histogram() {
   413   void Histogram::SetValidRange(
double binStart, 
double binEnd) {
   414     if (binEnd < binStart) {
   415       string msg = 
"The binning range start [" + 
IString(binStart) + 
"]"   416                    " must be less than the end [" + 
IString(binEnd) + 
"].";
   424     Isis::Statistics::SetValidRange(binStart,binEnd);
   425     p_binRangeStart = binStart;
   426     p_binRangeEnd = binEnd;
   431   void Histogram::Reset() {
   433     for (
int i = 0; i < (int)p_bins.size(); i++) {
   440   void Histogram::SetBins(
const int nbins) {
   441     p_bins.resize(nbins);
   453   void Histogram::AddData(
const double *data,
   454                           const unsigned int count) {
   455     Statistics::AddData(data, count);
   457     int nbins = p_bins.size();
   459     for (
unsigned int i = 0; i < count; i++) {
   461         if (BinRangeStart() == BinRangeEnd() ) {
   465           index = (int) floor((
double)(nbins - 1) / (BinRangeEnd() - BinRangeStart()) *
   466                               (data[i] - BinRangeStart() ) + 0.5);
   468         if (index < 0) index = 0;
   469         if (index >= nbins) index = nbins - 1;
   483   void Histogram::AddData(
const double data) {
   484     Statistics::AddData(data);
   486     int nbins = p_bins.size();
   489       if (BinRangeStart() == BinRangeEnd() ) {
   493         index = (int) floor((
double)(nbins - 1) / (BinRangeEnd() - BinRangeStart() ) *
   494                             (data - BinRangeStart() ) + 0.5);
   496       if (index < 0) index = 0;
   497       if (index >= nbins) index = nbins - 1;
   512   void Histogram::RemoveData(
const double *data,
   513                              const unsigned int count) {
   514     Statistics::RemoveData(data, count);
   516     int nbins = p_bins.size();
   518     for (
unsigned int i = 0; i < count; i++) {
   521         if (BinRangeStart() == BinRangeEnd() ) {
   525           index = (int) floor((
double)(nbins - 1) / (BinRangeEnd() - BinRangeStart()) *
   526                               (data[i] - BinRangeStart()) + 0.5);
   528         if (index < 0) index = 0;
   529         if (index >= nbins) index = nbins - 1;
   540   double Histogram::Median()
 const {
   541     return Percent(50.0);
   549   double Histogram::Mode()
 const {
   551     for (
int i = 0; i < (int)p_bins.size(); i++) {
   553       if (p_bins[i] > p_bins[mode]) mode = i;
   556     if (p_bins[mode] < 1) 
return NULL8;
   558     return BinMiddle(mode);
   572   double Histogram::Percent(
double percent)
 const {
   573     if ( (percent < 0.0) || (percent > 100.0) ) {
   574       string m = 
"Argument percent outside of the range 0 to 100 in";
   575       m += 
" [Histogram::Percent]";
   579     if (ValidPixels() < 1) 
return NULL8;
   582     double currentPercent;
   584     for (
int i = 0; i < (int)p_bins.size(); i++) {
   586       currentPixels += p_bins[i];
   587       currentPercent = (double) currentPixels / (
double) ValidPixels() * 100.0;
   589       if (currentPercent >= percent) {
   594     return BinMiddle( (
int)p_bins.size() - 1);
   605   double Histogram::Skew()
 const {
   607     if (ValidPixels() < 1) 
return NULL8;
   609     double sdev = StandardDeviation();
   611     if (sdev == 0.0) 
return 0.0;
   613     return 3.0 * (
Average() - Median()) / sdev;
   624   BigInt Histogram::BinCount(
const int index)
 const {
   626     if ( (index < 0) || (index >= (
int)p_bins.size() ) ) {
   633     return p_bins[index];
   648   void Histogram::BinRange(
const int index,
   649                            double &low, 
double &high)
 const {
   650     if ( (index < 0) || (index >= (
int)p_bins.size() ) ) {
   656     double binSize = (BinRangeEnd() - BinRangeStart()) / (
double)(p_bins.size() - 1);
   657     low = BinRangeStart() - binSize / 2.0 + binSize * (double) index;
   658     high = low + binSize;
   670   double Histogram::BinMiddle(
const int index)
 const {
   671     if ( (index < 0) || (index >= (
int)p_bins.size() ) ) {
   679     BinRange(index, low, high);
   680     return (low + high) / 2.0;
   691   double Histogram::BinSize()
 const {
   694     BinRange(0, low, high);
   704   int Histogram::Bins()
 const {
   705     return (
int)p_bins.size();
   717     for (
int i = 0; i < (int)p_bins.size(); i++) {
   718       if (p_bins[i] > maxBinCount) maxBinCount = p_bins[i];
 long long int BigInt
Big int. 
 
const double Null
Value for an Isis Null pixel. 
 
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process. 
 
const double ValidMinimum
The minimum valid double value for Isis pixels. 
 
const ControlMeasure * GetMeasure(QString serialNumber) const
Get a control measure based on its cube's serial number. 
 
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit. 
 
Buffer for containing a three dimensional section of an image. 
 
Namespace for the standard library. 
 
bool IsValidPixel(const double d)
Returns if the input pixel is valid. 
 
void CheckStatus()
Checks and updates the status. 
 
int GetNumPoints() const
Return the number of control points in the network. 
 
Program progress reporter. 
 
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed. 
 
#define _FILEINFO_
Macro for the filename and line number. 
 
void read(Blob &blob) const
This method will read data from the specified Blob object. 
 
bool IsSpecial(const double d)
Returns if the input pixel is special. 
 
PixelType pixelType() const
 
QString ArraySubscriptNotInRange(int index)
This error should be used when an Isis object or application is checking array bounds and the legal r...
 
const double ValidMaximum
The maximum valid double value for Isis pixels. 
 
Adds specific functionality to C++ strings. 
 
Namespace for ISIS/Bullet specific routines. 
 
virtual int bandCount() const
Returns the number of virtual bands for the cube. 
 
Functor for reduce using average functionality. 
 
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit. 
 
IO Handler for Isis Cubes.