From 8688032282e1c893e0076799d825038511b7e816 Mon Sep 17 00:00:00 2001 From: Kaitlyn Lee Date: Wed, 10 Jun 2020 14:06:44 -0700 Subject: [PATCH 1/7] Changed how the bins are calculated and where the data goes. --- isis/src/base/objs/Histogram/Histogram.cpp | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/isis/src/base/objs/Histogram/Histogram.cpp b/isis/src/base/objs/Histogram/Histogram.cpp index d8d60c2638..71e10b325a 100644 --- a/isis/src/base/objs/Histogram/Histogram.cpp +++ b/isis/src/base/objs/Histogram/Histogram.cpp @@ -50,7 +50,6 @@ namespace Isis { Histogram::Histogram(double minimum, double maximum, int nbins) { SetValidRange(minimum, maximum); - //SetBinRange(minimum, maximum); SetBins(nbins); } @@ -171,7 +170,7 @@ namespace Isis { //stretch the domain so that it is an even multiple of binWidth //for some reason Histogram makes the end points of the bin range be at the center of //bins. Thus the +/-0.5 forces it to point the bin range at the ends of the bins. - //SetBinRange(binWidth*( floor(this->ValidMinimum()/binWidth )+0.5), + //SetValidRange(binWidth*( floor(this->ValidMinimum()/binWidth )+0.5), // binWidth*(ceil( this->ValidMaximum()/binWidth )-0.5) ); @@ -266,7 +265,6 @@ namespace Isis { //set up the histogram ranges SetValidRange(min, max); - //SetBinRange(min, max); } @@ -396,7 +394,7 @@ namespace Isis { Histogram::~Histogram() { } - //2015-08-24, Tyler Wilson: Added Statistics::SetValidRange call to SetBinRange + //2015-08-24, Tyler Wilson: Added Statistics::SetValidRange call to SetValidRange //So the two functions do not have to be called together when setting //up a histogram @@ -462,8 +460,10 @@ namespace Isis { index = 0; } else { - index = (int) floor((double)(nbins - 1) / (BinRangeEnd() - BinRangeStart()) * - (data[i] - BinRangeStart() ) + 0.5); + // index = (int) floor((double)(nbins - 1) / (BinRangeEnd() - BinRangeStart()) * + // (data[i] - BinRangeStart() ) + 0.5); + index = (int) floor( ((double) nbins / (BinRangeEnd() - BinRangeStart())) * + (data[i] - BinRangeStart()) ); } if (index < 0) index = 0; if (index >= nbins) index = nbins - 1; @@ -490,8 +490,8 @@ namespace Isis { index = 0; } else { - index = (int) floor((double)(nbins - 1) / (BinRangeEnd() - BinRangeStart() ) * - (data - BinRangeStart() ) + 0.5); + index = (int) floor( ((double) nbins / (BinRangeEnd() - BinRangeStart())) * + (data - BinRangeStart()) ); } if (index < 0) index = 0; if (index >= nbins) index = nbins - 1; @@ -522,8 +522,8 @@ namespace Isis { index = 0; } else { - index = (int) floor((double)(nbins - 1) / (BinRangeEnd() - BinRangeStart()) * - (data[i] - BinRangeStart()) + 0.5); + index = (int) floor( ((double) nbins / (BinRangeEnd() - BinRangeStart())) * + (data[i] - BinRangeStart()) ); } if (index < 0) index = 0; if (index >= nbins) index = nbins - 1; @@ -591,7 +591,7 @@ namespace Isis { } } - return BinMiddle( (int)p_bins.size() - 1); + return BinMiddle( (int) p_bins.size() - 1); } @@ -653,8 +653,11 @@ namespace Isis { throw IException(IException::Programmer, message, _FILEINFO_); } - double binSize = (BinRangeEnd() - BinRangeStart()) / (double)(p_bins.size() - 1); - low = BinRangeStart() - binSize / 2.0 + binSize * (double) index; + // double binSize = (BinRangeEnd() - BinRangeStart()) / (double)(p_bins.size() - 1); + // low = BinRangeStart() - binSize / 2.0 + binSize * (double) index; + // high = low + binSize; + double binSize = (BinRangeEnd() - BinRangeStart()) / (double) p_bins.size(); + low = BinRangeStart() + binSize * (double) index; high = low + binSize; } From 506a638dca5770aed96700d11b79d464b3319f66 Mon Sep 17 00:00:00 2001 From: Kaitlyn Lee Date: Thu, 11 Jun 2020 11:11:52 -0700 Subject: [PATCH 2/7] Changed hist's output to align with the changes to Histogram --- isis/src/base/apps/hist/main.cpp | 100 +++++++++++++++---------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/isis/src/base/apps/hist/main.cpp b/isis/src/base/apps/hist/main.cpp index 0cdb3458f9..cdfbbd0782 100644 --- a/isis/src/base/apps/hist/main.cpp +++ b/isis/src/base/apps/hist/main.cpp @@ -23,18 +23,18 @@ void IsisMain() { Cube *icube = p.SetInputCube("FROM"); UserInterface &ui = Application::GetUserInterface(); - if(!ui.WasEntered("TO") && !ui.IsInteractive()) { + if (!ui.WasEntered("TO") && !ui.IsInteractive()) { QString msg = "The [TO] parameter must be entered"; throw IException(IException::User, msg, _FILEINFO_); } // Setup the histogram Histogram hist(*icube, 1, p.Progress() ); - if(ui.WasEntered("MINIMUM") ) { - hist.SetValidRange(ui.GetDouble("MINIMUM"),ui.GetDouble("MAXIMUM") ); + if (ui.WasEntered("MINIMUM") ) { + hist.SetValidRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM") ); } - if(ui.WasEntered("NBINS")) { + if (ui.WasEntered("NBINS")) { hist.SetBins(ui.GetInteger("NBINS")); } @@ -44,53 +44,60 @@ void IsisMain() { p.Progress()->CheckStatus(); LineManager line(*icube); - for(int i = 1; i <= icube->lineCount(); i++) { + for (int i = 1; i <= icube->lineCount(); i++) { line.SetLine(i); icube->read(line); hist.AddData(line.DoubleBuffer(), line.size()); p.Progress()->CheckStatus(); } - if(!ui.IsInteractive() || ui.WasEntered("TO") ) { + if (ui.WasEntered("TO") ) { // Write the results QString outfile = ui.GetFileName("TO"); ofstream fout; fout.open(outfile.toLatin1().data()); - fout << "Cube: " << ui.GetFileName("FROM") << endl; - fout << "Band: " << icube->bandCount() << endl; - fout << "Average: " << hist.Average() << endl; - fout << "Std Deviation: " << hist.StandardDeviation() << endl; - fout << "Variance: " << hist.Variance() << endl; - fout << "Median: " << hist.Median() << endl; - fout << "Mode: " << hist.Mode() << endl; - fout << "Skew: " << hist.Skew() << endl; - fout << "Minimum: " << hist.Minimum() << endl; - fout << "Maximum: " << hist.Maximum() << endl; + fout << "Cube: " << ui.GetFileName("FROM") << endl; + fout << "Band: " << icube->bandCount() << endl; + fout << "Average: " << hist.Average() << endl; + fout << "Std Deviation: " << hist.StandardDeviation() << endl; + fout << "Variance: " << hist.Variance() << endl; + fout << "Median: " << hist.Median() << endl; + fout << "Mode: " << hist.Mode() << endl; + fout << "Skew: " << hist.Skew() << endl; + fout << "Minimum: " << hist.Minimum() << endl; + fout << "Maximum: " << hist.Maximum() << endl; fout << endl; - fout << "Total Pixels: " << hist.TotalPixels() << endl; - fout << "Valid Pixels: " << hist.ValidPixels() << endl; - fout << "Null Pixels: " << hist.NullPixels() << endl; - fout << "Lis Pixels: " << hist.LisPixels() << endl; - fout << "Lrs Pixels: " << hist.LrsPixels() << endl; - fout << "His Pixels: " << hist.HisPixels() << endl; - fout << "Hrs Pixels: " << hist.HrsPixels() << endl; + fout << "Total Pixels: " << hist.TotalPixels() << endl; + fout << "Valid Pixels: " << hist.ValidPixels() << endl; + fout << "Pixels Below Min: " << hist.UnderRangePixels() << endl; + fout << "Pixels Above Max: " << hist.OverRangePixels() << endl; + fout << "Null Pixels: " << hist.NullPixels() << endl; + fout << "Lis Pixels: " << hist.LisPixels() << endl; + fout << "Lrs Pixels: " << hist.LrsPixels() << endl; + fout << "His Pixels: " << hist.HisPixels() << endl; + fout << "Hrs Pixels: " << hist.HrsPixels() << endl; // Write histogram in tabular format fout << endl; fout << endl; - fout << "DN,Pixels,CumulativePixels,Percent,CumulativePercent" << endl; + fout << "MinInclusive,MaxExclusive,Pixels,CumulativePixels,Percent,CumulativePercent" << endl; Isis::BigInt total = 0; double cumpct = 0.0; + double low; + double high; - for(int i = 0; i < hist.Bins(); i++) { - if(hist.BinCount(i) > 0) { + for (int i = 0; i < hist.Bins(); i++) { + if (hist.BinCount(i) > 0) { total += hist.BinCount(i); double pct = (double)hist.BinCount(i) / hist.ValidPixels() * 100.; cumpct += pct; - fout << hist.BinMiddle(i) << ","; + hist.BinRange(i, low, high); + + fout << low << ","; + fout << high << ","; fout << hist.BinCount(i) << ","; fout << total << ","; fout << pct << ","; @@ -100,10 +107,10 @@ void IsisMain() { fout.close(); } // If we are in gui mode, create a histogram plot - if(ui.IsInteractive()) { + if (ui.IsInteractive()) { // Set the title for the dialog QString title; - if(ui.WasEntered("TITLE") ) { + if (ui.WasEntered("TITLE") ) { title = ui.GetString("TITLE"); } else { @@ -116,19 +123,19 @@ void IsisMain() { ui.TheGui()); // Set the xaxis title if they entered one - if(ui.WasEntered("XAXIS") ) { + if (ui.WasEntered("XAXIS") ) { QString xaxis(ui.GetString("XAXIS")); plot->setAxisLabel(QwtPlot::xBottom, xaxis.toLatin1().data()); } // Set the yLeft axis title if they entered one - if(ui.WasEntered("FREQAXIS") ) { + if (ui.WasEntered("FREQAXIS") ) { QString yaxis(ui.GetString("FREQAXIS")); plot->setAxisLabel(QwtPlot::yRight, yaxis.toLatin1().data()); } // Set the yRight axis title if they entered one - if(ui.WasEntered("PERCENTAXIS") ) { + if (ui.WasEntered("PERCENTAXIS") ) { QString y2axis(ui.GetString("PERCENTAXIS") ); plot->setAxisLabel(QwtPlot::yLeft, y2axis.toLatin1().data()); } @@ -137,13 +144,16 @@ void IsisMain() { QVector binCountData; QVector cumPctData; double cumpct = 0.0; - for(int i = 0; i < hist.Bins(); i++) { - if(hist.BinCount(i) > 0) { - binCountData.append(QPointF(hist.BinMiddle(i), hist.BinCount(i) ) ); - - double pct = (double)hist.BinCount(i) / hist.ValidPixels() * 100.; + double low; + double high; + for (int i = 0; i < hist.Bins(); i++) { + if (hist.BinCount(i) > 0) { + hist.BinRange(i, low, high); + binCountData.append(QPointF(low, hist.BinCount(i) ) ); + + double pct = (double)hist.BinCount(i) / hist.ValidPixels() * 100.0; cumpct += pct; - cumPctData.append(QPointF(hist.BinMiddle(i), cumpct) ); + cumPctData.append(QPointF(low, cumpct) ); } } @@ -162,21 +172,13 @@ void IsisMain() { cdfCurve->setYAxis(QwtPlot::yLeft); cdfCurve->setPen(*pen); - //These are all variables needed in the following for loop. - //---------------------------------------------- QVector intervals(binCountData.size() ); -// double maxYValue = DBL_MIN; -// double minYValue = DBL_MAX; -// // --------------------------------------------- -// - for(int y = 0; y < binCountData.size(); y++) { + for (int y = 0; y < binCountData.size(); y++) { intervals[y].interval = QwtInterval(binCountData[y].x(), binCountData[y].x() + hist.BinSize()); intervals[y].value = binCountData[y].y(); -// if(values[y] > maxYValue) maxYValue = values[y]; -// if(values[y] < minYValue) minYValue = values[y]; } QPen percentagePen(Qt::red); @@ -189,10 +191,6 @@ void IsisMain() { plot->add(histCurve); plot->add(cdfCurve); -// plot->fillTable(); - -// plot->setScale(QwtPlot::yLeft, 0, maxYValue); -// plot->setScale(QwtPlot::xBottom, hist.Minimum(), hist.Maximum()); QLabel *label = new QLabel(" Average = " + QString::number(hist.Average()) + '\n' + "\n Minimum = " + QString::number(hist.Minimum()) + '\n' + From fb1a3dbbe5a797e891213417b33e216def904c42 Mon Sep 17 00:00:00 2001 From: Kaitlyn Lee Date: Thu, 11 Jun 2020 13:21:46 -0700 Subject: [PATCH 3/7] Added changes to cnethist --- isis/src/control/apps/cnethist/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/isis/src/control/apps/cnethist/main.cpp b/isis/src/control/apps/cnethist/main.cpp index 22bd9af0de..5a40079f99 100644 --- a/isis/src/control/apps/cnethist/main.cpp +++ b/isis/src/control/apps/cnethist/main.cpp @@ -124,18 +124,23 @@ void IsisMain() { // Write histogram in tabular format fout << endl; - fout << "ResidualMagnitude,MeasuresInBin,CumulativeMeasures,Percent,CumulativePercent" << endl; + fout << "ResidualMagnitudeMin,ResidualMagnitudeMax,MeasuresInBin,CumulativeMeasures,Percent,CumulativePercent" << endl; Isis::BigInt total = 0; double cumpct = 0.0; + double low; + double high; for(int j = 0; j < hist->Bins(); j++) { if(hist->BinCount(j) > 0) { total += hist->BinCount(j); double pct = (double)hist->BinCount(j) / hist->ValidPixels() * 100.; cumpct += pct; + + hist->BinRange(j, low, high); - fout << hist->BinMiddle(j) << ","; + fout << low << ","; + fout << high << ","; fout << hist->BinCount(j) << ","; fout << total << ","; fout << pct << ","; @@ -152,9 +157,12 @@ void IsisMain() { if(ui.IsInteractive()) { //Transfer data from histogram to the plotcurve QVector binCountData; + double low; + double high; for(int j = 0; j < hist->Bins(); j++) { if(hist->BinCount(j) > 0) { - binCountData.append(QPointF(hist->BinMiddle(j), hist->BinCount(j))); + hist->BinRange(j, low, high); + binCountData.append(QPointF(low, hist->BinCount(j))); } } From dfacc2ae8491fa37773d397bac1f911fab31c683 Mon Sep 17 00:00:00 2001 From: Kaitlyn Lee Date: Thu, 11 Jun 2020 13:43:50 -0700 Subject: [PATCH 4/7] Added history entries --- isis/src/base/apps/hist/hist.xml | 6 ++++++ isis/src/base/objs/Histogram/Histogram.cpp | 5 ----- isis/src/base/objs/Histogram/Histogram.h | 5 +++++ isis/src/control/apps/cnethist/cnethist.xml | 6 ++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/isis/src/base/apps/hist/hist.xml b/isis/src/base/apps/hist/hist.xml index 7a122450ba..327cc674d8 100644 --- a/isis/src/base/apps/hist/hist.xml +++ b/isis/src/base/apps/hist/hist.xml @@ -80,6 +80,12 @@ Changed the application to fail immediately if the TO argument is not entered from the commandline. Fixes #3914. + + Added "Pixels Below Min" and "Pixels Above Max" to the CSV output and changed how the data is + outputted. Originally, the CSV output and the GUI histogram would use the DN value in the + middle of a bin to represent that bin. That is, the CSV output used to have a "DN" value that + was the bin's middle pixel DN. This was not intuitive to users. Removed the "DN" value and added "MinInclusive" and "MaxExclusive" to the CSV so that bins are represented by their min/max values. These changes were also reflected in the histrogram creation. The x-axis is now based off of the min value of a bin instead of the middle value. These changes were made alongside changes made to Histogram and cnethist. + diff --git a/isis/src/base/objs/Histogram/Histogram.cpp b/isis/src/base/objs/Histogram/Histogram.cpp index 71e10b325a..96150e0e17 100644 --- a/isis/src/base/objs/Histogram/Histogram.cpp +++ b/isis/src/base/objs/Histogram/Histogram.cpp @@ -460,8 +460,6 @@ namespace Isis { index = 0; } else { - // index = (int) floor((double)(nbins - 1) / (BinRangeEnd() - BinRangeStart()) * - // (data[i] - BinRangeStart() ) + 0.5); index = (int) floor( ((double) nbins / (BinRangeEnd() - BinRangeStart())) * (data[i] - BinRangeStart()) ); } @@ -653,9 +651,6 @@ namespace Isis { throw IException(IException::Programmer, message, _FILEINFO_); } - // double binSize = (BinRangeEnd() - BinRangeStart()) / (double)(p_bins.size() - 1); - // low = BinRangeStart() - binSize / 2.0 + binSize * (double) index; - // high = low + binSize; double binSize = (BinRangeEnd() - BinRangeStart()) / (double) p_bins.size(); low = BinRangeStart() + binSize * (double) index; high = low + binSize; diff --git a/isis/src/base/objs/Histogram/Histogram.h b/isis/src/base/objs/Histogram/Histogram.h index 5f6c33ddb6..70c97c23fd 100644 --- a/isis/src/base/objs/Histogram/Histogram.h +++ b/isis/src/base/objs/Histogram/Histogram.h @@ -81,6 +81,11 @@ namespace Isis { * #1673. * @history 2018-07-27 Jesse Mapel - Added support for initializing a histogram from * signed and unsigned word cubes. References #971. + * @history 2020-06-11 Kaitlyn Lee - Changed how to detemine which bin a pixel/measure falls + * into in AddData(). Changed how the bin range is calculated in + * BinRange(). The math for these functions were incorrect and not + * intuitive. These changes were made alongside changes made + * to cnethist and hist. */ class Histogram : public Statistics { diff --git a/isis/src/control/apps/cnethist/cnethist.xml b/isis/src/control/apps/cnethist/cnethist.xml index a57d7b2e08..63555d91cb 100644 --- a/isis/src/control/apps/cnethist/cnethist.xml +++ b/isis/src/control/apps/cnethist/cnethist.xml @@ -17,6 +17,12 @@ Original version + + Removed "ResidualMagnitude" from the CSV output and added "ResidualMagnitudeMin" and "ResidualMagnitudeMax". This way, the bins are represented by the min/max values of the + bins instead of the DN of the pixel in the middle of the bin. These changes were also + reflected in the histrogram creation. The x-axis is now based off of the min value of a bin instead of the middle value. These changes were made alongside changes made to Histogram and hist. + + From b26fafc1a12325e5fa00ac266fbc66560cedd03e Mon Sep 17 00:00:00 2001 From: Austin Sanders Date: Fri, 12 Jun 2020 14:54:01 -0700 Subject: [PATCH 5/7] Changed histogram binning logic --- isis/src/base/apps/hist/hist.xml | 8 +-- isis/src/base/apps/hist/main.cpp | 56 ++++++++++----------- isis/src/base/objs/Histogram/Histogram.cpp | 12 ----- isis/src/base/objs/Histogram/Histogram.h | 6 +-- isis/src/control/apps/cnethist/cnethist.xml | 6 +-- isis/src/control/apps/cnethist/main.cpp | 28 +++++------ 6 files changed, 52 insertions(+), 64 deletions(-) diff --git a/isis/src/base/apps/hist/hist.xml b/isis/src/base/apps/hist/hist.xml index 84f8c38681..e0d4171a04 100644 --- a/isis/src/base/apps/hist/hist.xml +++ b/isis/src/base/apps/hist/hist.xml @@ -79,17 +79,17 @@ Changed the application to fail immediately if the TO argument is not entered from the commandline. Fixes #3914. - + Updated logic such that min/max values are no longer calculated from .cub if values are provided by the user. Fixes #3881. - Added "Pixels Below Min" and "Pixels Above Max" to the CSV output and changed how the data is - outputted. Originally, the CSV output and the GUI histogram would use the DN value in the + Added "Pixels Below Min" and "Pixels Above Max" to the CSV output and changed how the data is + outputted. Originally, the CSV output and the GUI histogram would use the DN value in the middle of a bin to represent that bin. That is, the CSV output used to have a "DN" value that was the bin's middle pixel DN. This was not intuitive to users. Removed the "DN" value and added "MinInclusive" and "MaxExclusive" to the CSV so that bins are represented by their min/max values. These changes were also reflected in the histrogram creation. The x-axis is now based off of the min value of a bin instead of the middle value. These changes were made alongside changes made to Histogram and cnethist. - + diff --git a/isis/src/base/apps/hist/main.cpp b/isis/src/base/apps/hist/main.cpp index 1134b5b237..de7be13ee8 100644 --- a/isis/src/base/apps/hist/main.cpp +++ b/isis/src/base/apps/hist/main.cpp @@ -81,24 +81,24 @@ void IsisMain() { fout << "Cube: " << ui.GetFileName("FROM") << endl; fout << "Band: " << icube->bandCount() << endl; - fout << "Average: " << hist.Average() << endl; - fout << "Std Deviation: " << hist.StandardDeviation() << endl; - fout << "Variance: " << hist.Variance() << endl; - fout << "Median: " << hist.Median() << endl; - fout << "Mode: " << hist.Mode() << endl; - fout << "Skew: " << hist.Skew() << endl; - fout << "Minimum: " << hist.Minimum() << endl; - fout << "Maximum: " << hist.Maximum() << endl; + fout << "Average: " << hist->Average() << endl; + fout << "Std Deviation: " << hist->StandardDeviation() << endl; + fout << "Variance: " << hist->Variance() << endl; + fout << "Median: " << hist->Median() << endl; + fout << "Mode: " << hist->Mode() << endl; + fout << "Skew: " << hist->Skew() << endl; + fout << "Minimum: " << hist->Minimum() << endl; + fout << "Maximum: " << hist->Maximum() << endl; fout << endl; - fout << "Total Pixels: " << hist.TotalPixels() << endl; - fout << "Valid Pixels: " << hist.ValidPixels() << endl; - fout << "Pixels Below Min: " << hist.UnderRangePixels() << endl; - fout << "Pixels Above Max: " << hist.OverRangePixels() << endl; - fout << "Null Pixels: " << hist.NullPixels() << endl; - fout << "Lis Pixels: " << hist.LisPixels() << endl; - fout << "Lrs Pixels: " << hist.LrsPixels() << endl; - fout << "His Pixels: " << hist.HisPixels() << endl; - fout << "Hrs Pixels: " << hist.HrsPixels() << endl; + fout << "Total Pixels: " << hist->TotalPixels() << endl; + fout << "Valid Pixels: " << hist->ValidPixels() << endl; + fout << "Pixels Below Min: " << hist->UnderRangePixels() << endl; + fout << "Pixels Above Max: " << hist->OverRangePixels() << endl; + fout << "Null Pixels: " << hist->NullPixels() << endl; + fout << "Lis Pixels: " << hist->LisPixels() << endl; + fout << "Lrs Pixels: " << hist->LrsPixels() << endl; + fout << "His Pixels: " << hist->HisPixels() << endl; + fout << "Hrs Pixels: " << hist->HrsPixels() << endl; // Write histogram in tabular format fout << endl; @@ -110,17 +110,17 @@ void IsisMain() { double low; double high; - for (int i = 0; i < hist.Bins(); i++) { - if (hist.BinCount(i) > 0) { - total += hist.BinCount(i); - double pct = (double)hist.BinCount(i) / hist.ValidPixels() * 100.; + for (int i = 0; i < hist->Bins(); i++) { + if (hist->BinCount(i) > 0) { + total += hist->BinCount(i); + double pct = (double)hist->BinCount(i) / hist->ValidPixels() * 100.; cumpct += pct; - hist.BinRange(i, low, high); + hist->BinRange(i, low, high); fout << low << ","; fout << high << ","; - fout << hist.BinCount(i) << ","; + fout << hist->BinCount(i) << ","; fout << total << ","; fout << pct << ","; fout << cumpct << endl; @@ -168,12 +168,12 @@ void IsisMain() { double cumpct = 0.0; double low; double high; - for (int i = 0; i < hist.Bins(); i++) { - if (hist.BinCount(i) > 0) { - hist.BinRange(i, low, high); - binCountData.append(QPointF(low, hist.BinCount(i) ) ); + for (int i = 0; i < hist->Bins(); i++) { + if (hist->BinCount(i) > 0) { + hist->BinRange(i, low, high); + binCountData.append(QPointF(low, hist->BinCount(i) ) ); - double pct = (double)hist.BinCount(i) / hist.ValidPixels() * 100.0; + double pct = (double)hist->BinCount(i) / hist->ValidPixels() * 100.0; cumpct += pct; cumPctData.append(QPointF(low, cumpct) ); } diff --git a/isis/src/base/objs/Histogram/Histogram.cpp b/isis/src/base/objs/Histogram/Histogram.cpp index 96150e0e17..2414a2e106 100644 --- a/isis/src/base/objs/Histogram/Histogram.cpp +++ b/isis/src/base/objs/Histogram/Histogram.cpp @@ -166,21 +166,9 @@ namespace Isis { rangesFromNet(net,statFunc); - - //stretch the domain so that it is an even multiple of binWidth - //for some reason Histogram makes the end points of the bin range be at the center of - //bins. Thus the +/-0.5 forces it to point the bin range at the ends of the bins. - //SetValidRange(binWidth*( floor(this->ValidMinimum()/binWidth )+0.5), - // binWidth*(ceil( this->ValidMaximum()/binWidth )-0.5) ); - - //Keep an eye on this to see if it breaks anything. Also, I need to create //a dataset to give this constructor for the unit test. - //tjw: SetValidRange is moved into SetBinRange - //SetValidRange(binWidth*floor(this->ValidMinimum()/binWidth), - // binWidth*ceil(this->ValidMaximum()/binWidth)); - //from the domain of the data and the requested bin width calculate the number of bins double domain = this->ValidMaximum() - this->ValidMinimum(); int nBins = int ( ceil(domain/binWidth) ); diff --git a/isis/src/base/objs/Histogram/Histogram.h b/isis/src/base/objs/Histogram/Histogram.h index 70c97c23fd..430a82169d 100644 --- a/isis/src/base/objs/Histogram/Histogram.h +++ b/isis/src/base/objs/Histogram/Histogram.h @@ -81,10 +81,10 @@ namespace Isis { * #1673. * @history 2018-07-27 Jesse Mapel - Added support for initializing a histogram from * signed and unsigned word cubes. References #971. - * @history 2020-06-11 Kaitlyn Lee - Changed how to detemine which bin a pixel/measure falls - * into in AddData(). Changed how the bin range is calculated in + * @history 2020-06-11 Kaitlyn Lee - Changed how to detemine which bin a pixel/measure falls + * into in AddData(). Changed how the bin range is calculated in * BinRange(). The math for these functions were incorrect and not - * intuitive. These changes were made alongside changes made + * intuitive. These changes were made alongside changes made * to cnethist and hist. */ diff --git a/isis/src/control/apps/cnethist/cnethist.xml b/isis/src/control/apps/cnethist/cnethist.xml index 63555d91cb..0e7f1c8c13 100644 --- a/isis/src/control/apps/cnethist/cnethist.xml +++ b/isis/src/control/apps/cnethist/cnethist.xml @@ -19,10 +19,10 @@ Removed "ResidualMagnitude" from the CSV output and added "ResidualMagnitudeMin" and "ResidualMagnitudeMax". This way, the bins are represented by the min/max values of the - bins instead of the DN of the pixel in the middle of the bin. These changes were also + bins instead of the DN of the pixel in the middle of the bin. These changes were also reflected in the histrogram creation. The x-axis is now based off of the min value of a bin instead of the middle value. These changes were made alongside changes made to Histogram and hist. - - + + diff --git a/isis/src/control/apps/cnethist/main.cpp b/isis/src/control/apps/cnethist/main.cpp index 5a40079f99..6fc5dcc15a 100644 --- a/isis/src/control/apps/cnethist/main.cpp +++ b/isis/src/control/apps/cnethist/main.cpp @@ -39,7 +39,7 @@ void IsisMain() { HistogramPlotWindow *plot=NULL; //setup plot tile and axis labels (if any) - if(ui.IsInteractive()) { + if(ui.IsInteractive()) { // Set the title for the dialog QString title; if(ui.WasEntered("TITLE")) { @@ -70,24 +70,24 @@ void IsisMain() { } QString yaxis = ""; - plot->setAxisLabel(QwtPlot::yRight, yaxis); + plot->setAxisLabel(QwtPlot::yRight, yaxis); } //open text report file (if any) - ofstream fout; - if(!ui.IsInteractive() || ui.WasEntered("TO")) { + ofstream fout; + if(!ui.IsInteractive() || ui.WasEntered("TO")) { // Write the results if(!ui.WasEntered("TO")) { QString msg = "The [TO] parameter must be entered"; throw IException(IException::User, msg, _FILEINFO_); } - QString outfile = ui.GetFileName("TO"); + QString outfile = ui.GetFileName("TO"); fout.open(outfile.toLatin1().data()); } //loop throught the control nets writing reports and drawing histograms as needed - for (int i=0;iAverage() << endl; @@ -121,7 +121,7 @@ void IsisMain() { fout << "Minimum: " << hist->Minimum() << endl; fout << "Maximum: " << hist->Maximum() << endl; fout << "Total Measures: " << hist->TotalPixels() << endl; - + // Write histogram in tabular format fout << endl; fout << "ResidualMagnitudeMin,ResidualMagnitudeMax,MeasuresInBin,CumulativeMeasures,Percent,CumulativePercent" << endl; @@ -138,7 +138,7 @@ void IsisMain() { cumpct += pct; hist->BinRange(j, low, high); - + fout << low << ","; fout << high << ","; fout << hist->BinCount(j) << ","; @@ -172,13 +172,13 @@ void IsisMain() { QString baseName = FileName(fList[i]).baseName(); histCurve->setTitle(baseName); - + QPen *pen = new QPen(curveColor(i)); pen->setWidth(2); histCurve->setYAxis(QwtPlot::yLeft); - histCurve->setPen(*pen); + histCurve->setPen(*pen); histCurve->setMarkerSymbol(QwtSymbol::NoSymbol); - + histCurve->setData(new QwtPointSeriesData(binCountData)); plot->add(histCurve); From a85327d182f3acae176de566fe7e91a180df740a Mon Sep 17 00:00:00 2001 From: Austin Sanders Date: Fri, 12 Jun 2020 15:20:24 -0700 Subject: [PATCH 6/7] Added ui.interactive check --- isis/src/base/apps/hist/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/isis/src/base/apps/hist/main.cpp b/isis/src/base/apps/hist/main.cpp index de7be13ee8..2b078ea2ee 100644 --- a/isis/src/base/apps/hist/main.cpp +++ b/isis/src/base/apps/hist/main.cpp @@ -73,7 +73,7 @@ void IsisMain() { p.Progress()->CheckStatus(); } - if (ui.WasEntered("TO") ) { + if (!ui.IsInteractive() || ui.WasEntered("TO") ) { // Write the results QString outfile = ui.GetFileName("TO"); ofstream fout; From 5e8cd79670fff533ba97f9a9f30daf28246943a8 Mon Sep 17 00:00:00 2001 From: Austin Sanders Date: Fri, 12 Jun 2020 15:34:54 -0700 Subject: [PATCH 7/7] Removed extra history end tag --- isis/src/control/apps/cnethist/cnethist.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/isis/src/control/apps/cnethist/cnethist.xml b/isis/src/control/apps/cnethist/cnethist.xml index 0e7f1c8c13..860d03cf73 100644 --- a/isis/src/control/apps/cnethist/cnethist.xml +++ b/isis/src/control/apps/cnethist/cnethist.xml @@ -22,7 +22,6 @@ bins instead of the DN of the pixel in the middle of the bin. These changes were also reflected in the histrogram creation. The x-axis is now based off of the min value of a bin instead of the middle value. These changes were made alongside changes made to Histogram and hist. -