Commit 6ce1dc6a authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by GitHub
Browse files

Revert "Fix gaussstretch segfault (#5259)"

This reverts commit adf1ff71.
parent adf1ff71
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ release.
- Fixes embree shape models not being from .BDS extension files [5064](https://github.com/USGS-Astrogeology/ISIS3/issues/5064)
- Fixed failing shapemodel parameters when bullet was the preferred ray tracing engine but could not be created. [#5062](https://github.com/USGS-Astrogeology/ISIS3/issues/5062)
- Fixed version for Qt to prevent depreciations. [#5070](https://github.com/USGS-Astrogeology/ISIS3/issues/5070)
- Fixed gaussstretch segmentation fault error and refactored gaussstretch files/tests to use gtest. [#5240](https://github.com/DOI-USGS/ISIS3/issues/5240)

## [7.1.0] - 2022-07-27

+0 −55
Original line number Diff line number Diff line
#include "ProcessByLine.h"
#include "Statistics.h"
#include "GaussianStretch.h"
#include "gaussstretch.h"

using namespace std;
using namespace Isis;

namespace Isis {

  void gaussstretch(UserInterface &ui) {
    Cube icube;
    CubeAttributeInput inAtt = ui.GetInputAttribute("FROM");
    if (inAtt.bands().size() != 0) {
      icube.setVirtualBands(inAtt.bands());
    }
    icube.open(ui.GetCubeName("FROM"));
    gaussstretch(&icube, ui);
  }

  void gaussstretch(Cube *icube, UserInterface &ui) {
    ProcessByLine p;
    p.SetInputCube(icube);
    QString outputFileName = ui.GetCubeName("TO");
    CubeAttributeOutput outputAttributes= ui.GetOutputAttribute("TO");
    p.SetOutputCube(outputFileName, outputAttributes, 
                    icube->sampleCount(), icube->lineCount(), icube->bandCount());
    double gsigma = ui.GetDouble("GSIGMA");

    vector<GaussianStretch *> stretch;
    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));
    }

    // Processing routine for the pca with one input cube
    auto gaussProcess = [&](Buffer &in, Buffer &out)->void {
      for(int i = 0; i < in.size(); i++) {
        if(IsSpecial(in[i])) out[i] = in[i];
        out[i] = stretch[in.Band(i)-1]->Map(in[i]);
      }
    };

    p.StartProcess(gaussProcess);
    for(int i = icube->bandCount()-1; i >= 0 ; i--) {
      delete stretch[i];
      stretch.pop_back();
    }
    p.EndProcess();

    stretch.clear();
  }
}
+0 −12
Original line number Diff line number Diff line
#ifndef gaussstretch_h
#define gaussstretch_h

#include "Cube.h"
#include "UserInterface.h"

namespace Isis {
    extern void gaussstretch(Cube *icube, UserInterface &ui);
    extern void gaussstretch(UserInterface &ui);
}

#endif
+37 −5
Original line number Diff line number Diff line
#include "Isis.h"

#include "gaussstretch.h"
#include "Application.h"
#include "ProcessByLine.h"
#include "Statistics.h"
#include "GaussianStretch.h"

using namespace std;
using namespace Isis;

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

vector<GaussianStretch *> stretch;

void IsisMain() {
  UserInterface &ui = Application::GetUserInterface();
  gaussstretch(ui);
  ProcessByLine p;
  Cube *icube = p.SetInputCube("FROM");
  p.SetOutputCube("TO");
  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));
  }

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

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

  stretch.clear();
}

// Processing routine for the pca with one input cube
void gauss(Buffer &in, Buffer &out) {
  for(int i = 0; i < in.size(); i++) {
    if(IsSpecial(in[i])) out[i] = in[i];
    out[i] = stretch[in.Band(i)-1]->Map(in[i]);
  }
}
+4 −0
Original line number Diff line number Diff line
BLANKS = "%-6s"    
LENGTH = "%-40s"

include $(ISISROOT)/make/isismake.tststree
Loading