Unverified Commit 1238d342 authored by kledmundson's avatar kledmundson Committed by GitHub
Browse files

Bandtrim has been refactored to be callable; old Makefile tests have been...

Bandtrim has been refactored to be callable; old Makefile tests have been converted to gtests. (#5572)

* Bandtrim has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Addresses #5571.

* Update FunctionalTestsBandtrim.cpp

Minor documentation change.
parent a28654ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ release.
- Added backplane options for SunIllumination and SurfaceObliqueDetectorResolution to phocube [#5467](https://github.com/DOI-USGS/ISIS3/issues/5467)

### Changed
- Bandtrim has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Issue: [#5571](https://github.com/USGS-Astrogeology/ISIS3/issues/5571)
- Modified kaguyasp2isis to work with new (detached) data [#5436](https://github.com/DOI-USGS/ISIS3/issues/5436)
- Added jigsaw error message for csminit'd images without csm parameters[#5486](https://github.com/DOI-USGS/ISIS3/issues/5486)
- Changed `qwt` dependency version to 6.2.0 or below [#5498](https://github.com/DOI-USGS/ISIS3/issues/5498)
+74 −0
Original line number Diff line number Diff line
/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "bandtrim.h"

#include "Cube.h"
#include "ProcessByBrick.h"
#include "SpecialPixel.h"

namespace Isis {

  // Process to trim spectral pixels if any are null
  void BandTrimSpectral(Buffer &in, Buffer &out);

  /**
   * Bandtrim searches for NULL pixels in all bands of a cube.
   * When a NULL pixel is found the corresponding pixel is set
   * to NULL in all other bands.
   *
   * @param ui User Interface with application parameters
   */
  void bandtrim(UserInterface &ui) {
  
    // open cube
    Cube icube;
    icube.open(ui.GetCubeName("FROM"));

    bandtrim(&icube, ui);
  }


  /**
   * Bandtrim searches for NULL pixels in all bands of a cube.
   * When a NULL pixel is found the corresponding pixel is set
   * to NULL in all other bands.
   *
   * @param icube Input cube
   * @param ui User Interface with application parameters
   */
  void bandtrim(Cube *icube, UserInterface &ui) {
    ProcessByBrick p;
    p.SetInputCube(icube);
    p.SetBrickSize(1, 1, icube->bandCount());

    QString fname = ui.GetCubeName("TO");
    CubeAttributeOutput &atts = ui.GetOutputAttribute("TO");
    p.SetOutputCube(fname, atts);

    p.StartProcess(BandTrimSpectral);
    p.EndProcess();
  }

  // Process to trim spectral pixels if any are null
  void BandTrimSpectral(Buffer &in, Buffer &out) {
    // Copy input to output and check to see if we should null
    bool nullPixels = false;
    for(int i = 0; i < in.size(); i++) {
      out[i] = in[i];
      if(in[i] == Isis::Null) nullPixels = true;
    }

    // Null all pixels in the spectra if necessary
    if(nullPixels) {
      for(int i = 0; i < in.size(); i++) {
        out[i] = Isis::Null;
      }
    }
  }
}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#ifndef bandtrim_h
#define bandtrim_h

#include "UserInterface.h"

namespace Isis{  
  extern void bandtrim(UserInterface &ui);
  extern void bandtrim(Cube *iCube, UserInterface &ui);
}

#endif
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@
    <change name="Steven Lambright" date="2008-05-12">
      Removed references to CubeInfo 
    </change>
    <change name="Ken Edmundson" date="2024-07-31">
      Converted to callable app and converted Makefile tests to gtests. 
    </change>
  </history>

  <groups>
+14 −28
Original line number Diff line number Diff line
#include "Isis.h"
#include "ProcessByBrick.h"
#include "SpecialPixel.h"
/** This is free and unencumbered software released into the public domain.

using namespace std;
using namespace Isis;
The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

void BandTrim(Buffer &in, Buffer &out);
/* SPDX-License-Identifier: CC0-1.0 */

void IsisMain() {
  ProcessByBrick p;
  Cube *icube = p.SetInputCube("FROM");
  p.SetBrickSize(1, 1, icube->bandCount());
  p.SetOutputCube("TO");
  p.StartProcess(BandTrim);
  p.EndProcess();
}
#include "Isis.h"

// Trim spectral pixels if anyone of them is null
void BandTrim(Buffer &in, Buffer &out) {
  // Copy input to output and check to see if we should null
  bool nullPixels = false;
  for(int i = 0; i < in.size(); i++) {
    out[i] = in[i];
    if(in[i] == Isis::Null) nullPixels = true;
  }
#include "bandtrim.h"

  // Null all pixels in the spectra if necessary
  if(nullPixels) {
    for(int i = 0; i < in.size(); i++) {
      out[i] = Isis::Null;
    }
  }
#include "Application.h"

using namespace Isis;

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