Unverified Commit ebb3348e authored by Christine Kim's avatar Christine Kim Committed by GitHub
Browse files

Added min/max type selection option (#5455)

parent da7d0e01
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ release.
- Added new Hayabusa2 translation for `SpacecraftName` to accept `HAYABUSA2` [#5395](https://github.com/DOI-USGS/ISIS3/issues/5395)
- Added ALLOWERROR parameter to campt [#5393](https://github.com/DOI-USGS/ISIS3/pull/5393)
- OSIRIS-REx Tagcams instrument support, tests, and test data added [#5424](https://github.com/DOI-USGS/ISIS3/issues/5424)
- Added min/max type drop-down selection option in QView's Stretch tool [#5289](https://github.com/DOI-USGS/ISIS3/issues/5289)

## [8.1.0] - 2024-01-08

+77 −2
Original line number Diff line number Diff line
@@ -183,6 +183,29 @@ namespace Isis {
    connect(m_stretchBandComboBox, SIGNAL(currentIndexChanged(int)),
            this, SLOT(stretchBandChanged(int)));

    // Create drop-down selection option to set min/max type
    p_minMaxTypeSelection = new QComboBox();
    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 \
        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.";
    p_minMaxTypeSelection->setWhatsThis(text);
    p_minMaxTypeSelection->addItem("Best",      0);
    p_minMaxTypeSelection->addItem("Absolute",  1);
    p_minMaxTypeSelection->addItem("Chebyshev", 2);

    connect(p_minMaxTypeSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(changeStretch()));

    QDoubleValidator *dval = new QDoubleValidator(hbox);
    m_stretchMinEdit = new QLineEdit(hbox);
    m_stretchMinEdit->setValidator(dval);
@@ -306,6 +329,7 @@ namespace Isis {
    layout->addWidget(m_globalButton);
    layout->addWidget(m_stretchRegionalButton);
    layout->addWidget(m_stretchBandComboBox);
    layout->addWidget(p_minMaxTypeSelection);
    layout->addWidget(m_stretchMinEdit);
    layout->addWidget(m_stretchMaxEdit);
    layout->addWidget(advancedButton);
@@ -1035,6 +1059,9 @@ namespace Isis {
    MdiCubeViewport *cvp = cubeViewport();
    if(cvp == NULL) return;

    // Set the min/max based on selected type
    stretchMinMaxType(cvp);
    
    // Make sure the user didn't enter bad min/max and if so fix it
    double min = m_stretchMinEdit->text().toDouble();
    double max = m_stretchMaxEdit->text().toDouble();
@@ -1088,6 +1115,54 @@ namespace Isis {
    stretchChanged();
  }

  /**
   * Sets stretch for current band in active viewport given
   * the min/max type selection.
  */
  void StretchTool::stretchMinMaxType(CubeViewport *cvp) {
    // Get current band
    int bandId = m_stretchBandComboBox->currentIndex();
    int bandNum = cvp->grayBand();
    if(bandId == (int)Red) {
      bandNum = cvp->redBand();
    }
    else if(bandId == (int)Green) {
      bandNum = cvp->greenBand();
    }
    else if(bandId == (int)Blue) {
      bandNum = cvp->blueBand();
    }

    // Get current band statistics
    Statistics stats = statsFromCube(cvp->cube(), bandNum);
    
    // Set min/max given ComboBox selection
    int minMaxIndex = p_minMaxTypeSelection->currentIndex();
    double selectedMin = 0;
    double selectedMax = 0;

    if (minMaxIndex == 0) {
      // Best
      selectedMin = stats.BestMinimum();
      selectedMax = stats.BestMaximum();
    } else if (minMaxIndex == 1) {
      // Absolute
      selectedMin = stats.Minimum();
      selectedMax = stats.Maximum();
    } else if (minMaxIndex == 2) {
      // Chebyshev
      selectedMin = stats.ChebyshevMinimum();
      selectedMax = stats.ChebyshevMaximum();
    }

    QString qMin = QString::number(selectedMin);
    QString qMax = QString::number(selectedMax);

    // Set the min/max text
    m_stretchMinEdit->setText(qMin);
    m_stretchMaxEdit->setText(qMax);
  }


  /**
   * This methods shows and updates the advanced dialog.
+2 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ namespace Isis {

    private:
      void stretchRect(CubeViewport *cvp, QRect rect);
      void stretchMinMaxType(CubeViewport *cvp);

    private:
      AdvancedStretchDialog *m_advancedStretch; //!< The advanced dialog
@@ -192,6 +193,7 @@ namespace Isis {
      QAction *m_copyBands;              //!< Copy band stretch action

      QComboBox *m_stretchBandComboBox;  //!< Stretch combo box
      QComboBox *p_minMaxTypeSelection;  //!< Min/Max type combo box

      QLineEdit *m_stretchMinEdit;       //!< Min. line edit
      QLineEdit *m_stretchMaxEdit;       //!< Max. line edit