From 50b42210a70d8e1805e92e21901afe80f7279730 Mon Sep 17 00:00:00 2001 From: Adam Paquette Date: Fri, 4 Sep 2020 16:43:16 -0700 Subject: [PATCH 1/5] Changed check and set range logic/removed duplicate code --- isis/src/base/apps/isis2raw/main.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/isis/src/base/apps/isis2raw/main.cpp b/isis/src/base/apps/isis2raw/main.cpp index 0af54a711a..72c7e34422 100644 --- a/isis/src/base/apps/isis2raw/main.cpp +++ b/isis/src/base/apps/isis2raw/main.cpp @@ -37,8 +37,9 @@ void IsisMain() { // if(ui.GetString("BITTYPE") != "32BIT") p.SetInputRange(); } - if(ui.GetString("STRETCH") == "MANUAL") + if(ui.GetString("STRETCH") == "MANUAL") { p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); + } // Determine bit size, output range, and calculate number of bytes to write // for each line. @@ -48,25 +49,22 @@ void IsisMain() { p.SetOutputType(Isis::UnsignedByte); min = 0.0; max = 255.0; - checkRange(ui, min, max); - setRangeAndPixels(ui, p, min, max, BOTH); } else if(ui.GetString("BITTYPE") == "S16BIT") { p.SetOutputType(Isis::SignedWord); min = -32768.0; max = 32767.0; - checkRange(ui, min, max); - setRangeAndPixels(ui, p, min, max, NEG); } else if(ui.GetString("BITTYPE") == "U16BIT") { p.SetOutputType(Isis::UnsignedWord); min = 0.0; max = 65535.0; - checkRange(ui, min, max); - setRangeAndPixels(ui, p, min, max, BOTH); } else if(ui.GetString("BITTYPE") == "32BIT") { p.SetOutputType(Isis::Real); + } + + if (ui.GetString("STRETCH") != NONE && ui.GetString("BITTYPE") != "32BIT") { checkRange(ui, min, max); setRangeAndPixels(ui, p, min, max, NONE); } @@ -117,7 +115,7 @@ void IsisMain() { // Validates provided range void checkRange(UserInterface &ui, double &min, double &max) { Isis::Histogram *hist = p_cube->histogram(0); - + if(ui.WasEntered("OMIN")) { if(ui.GetDouble("OMIN") < min) { QString message = "OMIN [" + toString(min) + "] is too small for the provided BITTYPE ["; @@ -136,7 +134,7 @@ void checkRange(UserInterface &ui, double &min, double &max) { min = ui.GetDouble("MINIMUM"); } } - + if(ui.WasEntered("OMAX")) { if(ui.GetDouble("OMAX") > max) { QString message = "OMAX [" + toString(max) + "] is too large for the provided BITTYPE ["; From 63911792ce8d46a942a8f8bc974626c828d773cf Mon Sep 17 00:00:00 2001 From: Adam Paquette Date: Fri, 4 Sep 2020 16:48:43 -0700 Subject: [PATCH 2/5] Added history comment and moved function outside of if statement --- isis/src/base/apps/isis2raw/isis2raw.xml | 49 +++++++++++++----------- isis/src/base/apps/isis2raw/main.cpp | 4 +- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/isis/src/base/apps/isis2raw/isis2raw.xml b/isis/src/base/apps/isis2raw/isis2raw.xml index 0447771915..f9aa924cb4 100644 --- a/isis/src/base/apps/isis2raw/isis2raw.xml +++ b/isis/src/base/apps/isis2raw/isis2raw.xml @@ -11,12 +11,12 @@ The raw image may be output into an 8-bit, 16-bit unsigned, 16-bit signed or 32-bit raw image. This raw image can be in BSQ, BIL, or BIP format, and can include or exclude Null, LRS, LIS, HIS, and/or HRS specific DN values. - If no special pixel parameters are selected, then Low Saturation values and + If no special pixel parameters are selected, then Low Saturation values and Null values are set to black and High Saturation values are set to white. - To ensure acceptable contrast in the output file, the user may select from + To ensure acceptable contrast in the output file, the user may select from three stretch options are given 1) no stretch 2) linear, and 3) manual. - A custom maximum and minimum DN value can be specified for all output - bittypes. For example, if a range of 0 to 1023 is selected in a 16-bit + A custom maximum and minimum DN value can be specified for all output + bittypes. For example, if a range of 0 to 1023 is selected in a 16-bit unsigned raw image, the DNs are stretched to an effective 10-bit format. @@ -57,7 +57,7 @@ Fixed problem where the valid data range overlapped the null value. - Created options to ouput BIL and BIP formats, making BSQ the default, as + Created options to ouput BIL and BIP formats, making BSQ the default, as well as added preserve special pixel (NULL) option. @@ -72,6 +72,11 @@ output image. OMIN and OMAX are now calculated based on the stretch if 32-bit is chosen and the OMIN and OMAX fields are left blank. Fixes #2194. + + Updated application logic to not generate a histogram if stretch is None + and the output bit type is 32-bit. Also removes duplicate class to checkRange + and setRangeAndPixels. Closes #3878 (github). + @@ -173,15 +178,15 @@ The minimum output DN value including special pixels. - If a value is provided, the value will be the minimum DN used (including special - pixels). If left blank and the BITTYPE is not 32BIT, the minimum DN value - will default to the smallest value possible for the provided + If a value is provided, the value will be the minimum DN used (including special + pixels). If left blank and the BITTYPE is not 32BIT, the minimum DN value + will default to the smallest value possible for the provided BITTYPE. If the BITTYPE is 32BIT and OMIN is left blank, the value - of OMIN will depend on the STRETCH type chosen. If LINEAR is - chosen, the value for OMIN will be the DN value at the value - entered for MINPERCENT on the data. If MANUAL is chosen, the OMIN - will equal to the value of MINIMUM. If NONE is chosen, the value - will default to the smallest value possible for 32 bit data. + of OMIN will depend on the STRETCH type chosen. If LINEAR is + chosen, the value for OMIN will be the DN value at the value + entered for MINPERCENT on the data. If MANUAL is chosen, the OMIN + will equal to the value of MINIMUM. If NONE is chosen, the value + will default to the smallest value possible for 32 bit data. Refer to Documentation @@ -193,14 +198,14 @@ The maximum output DN value including special pixels. - If a value is provided, the value will be the maximum DN used (including special - pixels). If left blank and the BITTYPE is not 32BIT, the maximum DN value - will default to the largest value possible for the provided + If a value is provided, the value will be the maximum DN used (including special + pixels). If left blank and the BITTYPE is not 32BIT, the maximum DN value + will default to the largest value possible for the provided BITTYPE. If the BITTYPE is 32BIT and OMAX is left blank, the value - of OMAX will depend on the STRETCH type chosen. If LINEAR is - chosen, the value for OMAX will be the DN value at the value - entered for MAXPERCENT on the data. If MANUAL is chosen, the OMIN - will equal to the value of MAXIMUM. If NONE is chosen, the value + of OMAX will depend on the STRETCH type chosen. If LINEAR is + chosen, the value for OMAX will be the DN value at the value + entered for MAXPERCENT on the data. If MANUAL is chosen, the OMIN + will equal to the value of MAXIMUM. If NONE is chosen, the value will default to the largest value possible for 32 bit data. @@ -212,7 +217,7 @@ true Dedicates the minimum DN value for null pixels. - If set to true, the minimum value of the raw output data will be + If set to true, the minimum value of the raw output data will be reserved for null pixels. The actual value used for null pixels will be denoted in the print.prt file and displayed onscreen. @@ -403,7 +408,7 @@ Storage order of output file. - Sets the storage order of the raw ouput file to BSQ, BIL, or + Sets the storage order of the raw ouput file to BSQ, BIL, or BIP. diff --git a/isis/src/base/apps/isis2raw/main.cpp b/isis/src/base/apps/isis2raw/main.cpp index 72c7e34422..3c1c0a4fa5 100644 --- a/isis/src/base/apps/isis2raw/main.cpp +++ b/isis/src/base/apps/isis2raw/main.cpp @@ -63,11 +63,11 @@ void IsisMain() { else if(ui.GetString("BITTYPE") == "32BIT") { p.SetOutputType(Isis::Real); } - + if (ui.GetString("STRETCH") != NONE && ui.GetString("BITTYPE") != "32BIT") { checkRange(ui, min, max); - setRangeAndPixels(ui, p, min, max, NONE); } + setRangeAndPixels(ui, p, min, max, NONE); // Set the output endianness if(ui.GetString("ENDIAN") == "MSB") From e93a9ee2f678e2108d2cad97378ee6889fc18cee Mon Sep 17 00:00:00 2001 From: Adam Paquette Date: Fri, 4 Sep 2020 18:47:51 -0700 Subject: [PATCH 3/5] Fixed pixel type prapogation and boolean logic --- isis/src/base/apps/isis2raw/main.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/isis/src/base/apps/isis2raw/main.cpp b/isis/src/base/apps/isis2raw/main.cpp index 3c1c0a4fa5..e304b14425 100644 --- a/isis/src/base/apps/isis2raw/main.cpp +++ b/isis/src/base/apps/isis2raw/main.cpp @@ -45,29 +45,33 @@ void IsisMain() { // for each line. double min = -DBL_MAX; double max = DBL_MAX; + Pixtype pixType = NONE; if(ui.GetString("BITTYPE") == "8BIT") { p.SetOutputType(Isis::UnsignedByte); min = 0.0; max = 255.0; + pixType = BOTH; } else if(ui.GetString("BITTYPE") == "S16BIT") { p.SetOutputType(Isis::SignedWord); min = -32768.0; max = 32767.0; + pixType = NEG; } else if(ui.GetString("BITTYPE") == "U16BIT") { p.SetOutputType(Isis::UnsignedWord); min = 0.0; max = 65535.0; + pixType = BOTH; } else if(ui.GetString("BITTYPE") == "32BIT") { p.SetOutputType(Isis::Real); + pixType = NONE; } - - if (ui.GetString("STRETCH") != NONE && ui.GetString("BITTYPE") != "32BIT") { + if (ui.GetString("STRETCH") != "NONE" || ui.GetString("BITTYPE") != "32BIT") { checkRange(ui, min, max); } - setRangeAndPixels(ui, p, min, max, NONE); + setRangeAndPixels(ui, p, min, max, pixType); // Set the output endianness if(ui.GetString("ENDIAN") == "MSB") From 266794bb7df3113be18941f38560b2e4203bb557 Mon Sep 17 00:00:00 2001 From: Adam Paquette Date: Tue, 8 Sep 2020 11:42:41 -0700 Subject: [PATCH 4/5] Addressed PR feedback --- isis/src/base/apps/isis2raw/isis2raw.xml | 2 +- isis/src/base/apps/isis2raw/main.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/isis/src/base/apps/isis2raw/isis2raw.xml b/isis/src/base/apps/isis2raw/isis2raw.xml index f9aa924cb4..ab8d54a9f4 100644 --- a/isis/src/base/apps/isis2raw/isis2raw.xml +++ b/isis/src/base/apps/isis2raw/isis2raw.xml @@ -74,7 +74,7 @@ Updated application logic to not generate a histogram if stretch is None - and the output bit type is 32-bit. Also removes duplicate class to checkRange + and the output bit type is 32-bit. Also removes duplicate calls to checkRange and setRangeAndPixels. Closes #3878 (github). diff --git a/isis/src/base/apps/isis2raw/main.cpp b/isis/src/base/apps/isis2raw/main.cpp index e304b14425..74cbed6491 100644 --- a/isis/src/base/apps/isis2raw/main.cpp +++ b/isis/src/base/apps/isis2raw/main.cpp @@ -68,6 +68,7 @@ void IsisMain() { p.SetOutputType(Isis::Real); pixType = NONE; } + if (ui.GetString("STRETCH") != "NONE" || ui.GetString("BITTYPE") != "32BIT") { checkRange(ui, min, max); } From b91e1f6d64c5aef0e037a91cb2255df499ce65f0 Mon Sep 17 00:00:00 2001 From: Adam Paquette Date: Tue, 8 Sep 2020 11:52:10 -0700 Subject: [PATCH 5/5] Updated the changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbc9a7a6b8..671070e835 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,10 @@ update the Unreleased link so that it compares against the latest release tag. ## [Unreleased] +### Changed + + - Isis2raw will now output straight to a 32bit file (no stretch) when stretch is set to None and bittype is set to 32bit. [#3878](https://github.com/USGS-Astrogeology/ISIS3/issues/3878) + ### Fixed - Equalizer now reports the correct equation and values used to perform the adjustment. [#3987](https://github.com/USGS-Astrogeology/ISIS3/issues/3987)