From a5c02365f47da31e692e28458b0096d48abd97c7 Mon Sep 17 00:00:00 2001 From: Christine Kim <125395064+chkim-usgs@users.noreply.github.com> Date: Wed, 1 May 2024 09:36:24 -0400 Subject: [PATCH] Add qview stretch bugfix (#5492) * Add qview stretch bugfix * Update changelog --- CHANGELOG.md | 3 +++ .../qisis/objs/StretchTool/StretchTool.cpp | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49badccdf0..d6cc7a4fb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,9 @@ release. ## [Unreleased] +### Fixed +- Fixed a bug in QVIEW's Stretch tool where the default min/max type was not an available option [#5289](https://github.com/DOI-USGS/ISIS3/issues/5289) + ## [8.2.0] - 2024-04-18 ### Changed diff --git a/isis/src/qisis/objs/StretchTool/StretchTool.cpp b/isis/src/qisis/objs/StretchTool/StretchTool.cpp index 3ee41848c3..b747cdd878 100644 --- a/isis/src/qisis/objs/StretchTool/StretchTool.cpp +++ b/isis/src/qisis/objs/StretchTool/StretchTool.cpp @@ -188,21 +188,22 @@ namespace Isis { p_minMaxTypeSelection->setToolTip("Min/Max Type"); text = "<b>Function:</b> Select the minimum & maximum value types to \ - set the stretch to. The three options are: \ - <p>- Best: (default) The better of the absolute min/max or the \ + set the stretch to. The four options are: \ + <p>- Default: Min and max values are set to the \ + 0.5 and 99.5 percentiles, respectively. \ + <p>- Best: The better of the absolute min/max or the \ Chebyshev min/max. The better value is considered the value \ closest to the mean. \ <p>- Absolute: The absolute min/max value of all valid pixels. \ <p>- Chebyshev: The min/max value such that a certain percentage \ of data will fall within K standard deviations of the average \ (Chebyshev's Theorem). It can be used to obtain a value that \ - does not include statistical outliers. \ - <p><b>Hint:</b> Percentages are set to mininum of 0.5 and \ - maximum of 99.5."; + does not include statistical outliers."; p_minMaxTypeSelection->setWhatsThis(text); - p_minMaxTypeSelection->addItem("Best", 0); - p_minMaxTypeSelection->addItem("Absolute", 1); - p_minMaxTypeSelection->addItem("Chebyshev", 2); + p_minMaxTypeSelection->addItem("Default", 0); + p_minMaxTypeSelection->addItem("Best", 1); + p_minMaxTypeSelection->addItem("Absolute", 2); + p_minMaxTypeSelection->addItem("Chebyshev", 3); connect(p_minMaxTypeSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(changeStretch())); @@ -1135,6 +1136,7 @@ namespace Isis { // Get current band statistics Statistics stats = statsFromCube(cvp->cube(), bandNum); + Histogram hist = histFromCube(cvp->cube(), bandNum, stats.BestMinimum(), stats.BestMaximum()); // Set min/max given ComboBox selection int minMaxIndex = p_minMaxTypeSelection->currentIndex(); @@ -1142,14 +1144,17 @@ namespace Isis { double selectedMax = 0; if (minMaxIndex == 0) { + selectedMin = hist.Percent(0.5); + selectedMax = hist.Percent(99.5); + } else if (minMaxIndex == 1) { // Best selectedMin = stats.BestMinimum(); selectedMax = stats.BestMaximum(); - } else if (minMaxIndex == 1) { + } else if (minMaxIndex == 2) { // Absolute selectedMin = stats.Minimum(); selectedMax = stats.Maximum(); - } else if (minMaxIndex == 2) { + } else if (minMaxIndex == 3) { // Chebyshev selectedMin = stats.ChebyshevMinimum(); selectedMax = stats.ChebyshevMaximum(); -- GitLab