Skip to content

Commit

Permalink
Revert reverted histogram PR and handle conflicts. (#4004)
Browse files Browse the repository at this point in the history
* Revert reverted histogram PR and handle conflicts

* Added changelog entry

* ERROR

* local stats fix

* Added new ImageHistogram class

* Actually added the ImageHistogram class

* Made shared variable protected so subclass can access it

* Used virtual functions and reverted Cube::histogram to return a Historgram

* Added back pipe to dev/null in makefile

* Fixes to some app and unit test in the hist PR

* More test fixes

* Final updates to programs and test data for new histogram calculations

* Split the rolls of imagehistogram and histogram

* Added and updated unit test truth data

* Added the ImageHistogram unittest file

* Resolved last comments on hist PR

Co-authored-by: Adam Paquette <[email protected]>
  • Loading branch information
krlberry and acpaquette authored Sep 25, 2020
1 parent 644fea3 commit 0a96d6d
Show file tree
Hide file tree
Showing 35 changed files with 1,498 additions and 1,084 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ update the Unreleased link so that it compares against the latest release tag.

- Equalizer now reports the correct equation and values used to perform the adjustment. [#3987](https://github.com/USGS-Astrogeology/ISIS3/issues/3987)
- Map2cam now works correctly when specifying bands for input cubes. [#3856](https://github.com/USGS-Astrogeology/ISIS3/issues/3856)

- mro/hideal2pds app now writes the correct SAMPLE_BIT_MASK values to the output label. [#3978](https://github.com/USGS-Astrogeology/ISIS3/issues/3978)

- For Histograms in ISIS, updated the math for calculating what bin data should be placed in and the min/max values of each bin to be more intuitive. In addition, the output of hist and cnethist were changed to display the min/max values of each bin instead of the middle pixel's DN. [#3882](https://github.com/USGS-Astrogeology/ISIS3/issues/3882)

### Added
- A Gui Helper gear was added to hist to fill in the minimum and maximum parameters with what would have been automatically calculated. [#3880](https://github.com/USGS-Astrogeology/ISIS3/issues/3880)

- A Gui Helper gear was added to hist to fill in the minimum and maximum parameters with what would have been automatically calculated. [#3880](https://github.com/USGS-Astrogeology/ISIS3/issues/3880)

- Added some Python programs (in isis/scripts/) to manage the authoritative .zenodo.json file
which contains the ISIS authors, and to generate the AUTHORS.rst file from it.
Expand Down
40 changes: 20 additions & 20 deletions isis/src/base/apps/bit2bit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@
#include "Cube.h"
#include "Process.h"

using namespace std;
using namespace std;
using namespace Isis;

void populate(Buffer &in, Buffer &out);

void IsisMain(){
UserInterface &ui = Application::GetUserInterface();


//We will process by line
ProcessByLine p;
Cube* cubeptr = p.SetInputCube("FROM");


// Histogram* histptr = (cubeptr -> Histogram());
double max = ui.GetDouble("MAXVAL");
double min = ui.GetDouble("MINVAL");

/*
A histogram is made from the input cube, as the default min of the
bit2bit output is at .5% of the data range, and the default max is at 99.5%
*/
*/
Histogram* histptr = cubeptr -> histogram();

double maxper = histptr -> Percent(ui.GetDouble("MAXPER"));
double minper = histptr -> Percent(ui.GetDouble("MINPER"));
double validMin = Isis::ValidMinimum;
double validMax = Isis::ValidMaximum;



// Set properties MIN,MAX, and PixelType for output cube
CubeAttributeOutput outputProperties;
Expand All @@ -60,26 +60,26 @@ void IsisMain(){
}
else {
outputProperties.setPixelType(Real);
}
}


if(ui.GetBoolean("STATS")) { //! Run extended statistics
Cube* ocubeptr = p.SetOutputCube (ui.GetFileName("TO"),outputProperties,
cubeptr->sampleCount(),cubeptr->lineCount(),
cubeptr->bandCount());

p.StartProcess(populate);

Histogram* ohistptr = (ocubeptr -> histogram(1,validMin,validMax));
int iLrs = histptr -> LrsPixels();
int iHrs = histptr -> HrsPixels();
int iNull = histptr -> NullPixels();
int oLrs = ohistptr -> LrsPixels();
int oHrs = ohistptr -> HrsPixels();
int oNull = ohistptr -> NullPixels();
int oNull = ohistptr -> NullPixels();
double invalid_pi = (( (histptr -> TotalPixels()) - (histptr -> ValidPixels()))*100.0) / ((histptr -> TotalPixels())*1.0);
double invalid_po = (( (ohistptr -> TotalPixels()) - (ohistptr -> ValidPixels()))*100.0) / ((ohistptr -> TotalPixels())*1.0);
double invalid_po = (( (ohistptr -> TotalPixels()) - (ohistptr -> ValidPixels()))*100.0) / ((ohistptr -> TotalPixels())*1.0);

p.EndProcess();

//!Write bit2bit summary to the screen
Expand All @@ -95,7 +95,7 @@ void IsisMain(){
cout << " HRS:\t\t" << oHrs << endl;
cout << " NULL:\t\t" << oNull << endl;
cout << " Invalid Pixel %:\t\t" << invalid_po << endl<< endl;

//!Write bit2bit summary to print.prt logfile
PvlGroup results("bit2bit_Results");
results += PvlKeyword ("INPUT_LRS",toString(iLrs));
Expand All @@ -109,16 +109,16 @@ void IsisMain(){
results += PvlKeyword ("OUTPUT_NULL",toString(oNull));
results += PvlKeyword ("OUTPUT_INVALID_PERCENT",toString(invalid_po));
Application::Log(results);

delete histptr;
delete ohistptr;
delete ohistptr;
}
else{ //! run minimal statistics (runs faster)
int iLrs = histptr -> LrsPixels();
int iHrs = histptr -> HrsPixels();
int iNull = histptr -> NullPixels();
double invalid_pi = (( (histptr -> TotalPixels()) - (histptr -> ValidPixels()))*100.0) / ((histptr -> TotalPixels())*1.0);

p.EndProcess();

//!Write bit2bit summary to the screen
Expand All @@ -131,7 +131,7 @@ void IsisMain(){
cout << " Data Range:\t\t";
cout << validMin << " < x < " << validMax << endl;


//!Write bit2bit summary to print.prt logfile
PvlGroup results("bit2bit_Results");
results += PvlKeyword ("INPUT_LRS",toString(iLrs));
Expand All @@ -141,7 +141,7 @@ void IsisMain(){
results += PvlKeyword ("OUTPUT_MIN",toString(validMin));
results += PvlKeyword ("OUTPUT_MAX",toString(validMax));
Application::Log(results);

delete histptr;
}
}
Expand Down
17 changes: 11 additions & 6 deletions isis/src/base/apps/gaussstretch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ void IsisMain() {
double gsigma = Isis::Application::GetUserInterface().GetDouble("GSIGMA");

for(int i = 0; i < icube->bandCount(); i++) {
Histogram hist = *(icube->histogram(i + 1));
double mean = (hist.Maximum() + hist.Minimum()) / 2.0;
double stdev = (hist.Maximum() - hist.Minimum()) / (2.0 * gsigma);
stretch.push_back(new GaussianStretch(hist, mean, stdev));
Histogram *hist = icube->histogram(i + 1);
double mean = (hist->Maximum() + hist->Minimum()) / 2.0;
double stdev = (hist->Maximum() - hist->Minimum()) / (2.0 * gsigma);
stretch.push_back(new GaussianStretch(*hist, mean, stdev));
}

p.StartProcess(gauss);
for(int i = 0; i < icube->bandCount(); i++) delete stretch[i];
stretch.clear();
p.EndProcess();

while(!stretch.empty()) {
delete stretch.back();
stretch.pop_back();
}

stretch.clear();
}

// Processing routine for the pca with one input cube
Expand All @@ -36,4 +42,3 @@ void gauss(Buffer &in, Buffer &out) {
out[i] = stretch[in.Band(i)-1]->Map(in[i]);
}
}

6 changes: 6 additions & 0 deletions isis/src/base/apps/hist/hist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
Updated logic such that min/max values are no longer calculated from .cub
if values are provided by the user. Fixes #3881.
</change>
<change name="Kaitlyn Lee" date="2020-06-11">
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.
</change>
<change name="Kristin Berry" date="2020-06-25">
Re-added the ability to set number of bins without setting min/max values after the last update.
Follow-on to #3881.
Expand Down
Loading

0 comments on commit 0a96d6d

Please sign in to comment.