forked from DOI-USGS/ISIS3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Photrim has been refactored to be callable; old Makefile tests have b…
…een converted to gtests and removed. (DOI-USGS#5582) * Photrim has been converted to a callable app. Corresponding Makefile tests have been converted to gtests and removed. Addresses DOI-USGS#5581. * Tweaks to FunctionalTestsPhotrim.cpp. Addresses DOI-USGS#5581.
- Loading branch information
1 parent
ab5ed1d
commit 1d31047
Showing
12 changed files
with
463 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,20 @@ | ||
#include "Isis.h" | ||
#include "Camera.h" | ||
#include "ProcessByLine.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. **/ | ||
|
||
// Global variables | ||
Camera *cam; | ||
Cube *icube; | ||
bool usedem; | ||
double minPhase; | ||
double maxPhase; | ||
double minEmission; | ||
double maxEmission; | ||
double minIncidence; | ||
double maxIncidence; | ||
int lastBand; | ||
/* SPDX-License-Identifier: CC0-1.0 */ | ||
|
||
void photrim(Buffer &in, Buffer &out); | ||
#include "Isis.h" | ||
|
||
void IsisMain() { | ||
// We will be processing by line | ||
ProcessByLine p; | ||
#include "photrim.h" | ||
|
||
// Setup the input and get the camera model | ||
icube = p.SetInputCube("FROM"); | ||
cam = icube->camera(); | ||
#include "Application.h" | ||
|
||
// Create the output cube | ||
p.SetOutputCube("TO"); | ||
using namespace Isis; | ||
|
||
// Get the trim angles | ||
void IsisMain() { | ||
UserInterface &ui = Application::GetUserInterface(); | ||
|
||
minPhase = ui.GetDouble("MINPHASE"); | ||
maxPhase = ui.GetDouble("MAXPHASE"); | ||
minEmission = ui.GetDouble("MINEMISSION"); | ||
maxEmission = ui.GetDouble("MAXEMISSION"); | ||
minIncidence = ui.GetDouble("MININCIDENCE"); | ||
maxIncidence = ui.GetDouble("MAXINCIDENCE"); | ||
|
||
usedem = ui.GetBoolean("USEDEM"); | ||
|
||
if (!usedem) { | ||
cam->IgnoreElevationModel(true); | ||
|
||
} | ||
|
||
// Start the processing | ||
lastBand = 0; | ||
p.StartProcess(photrim); | ||
p.EndProcess(); | ||
} | ||
|
||
|
||
// Line processing routine | ||
void photrim(Buffer &in, Buffer &out) { | ||
// See if there is a change in band which would change the camera model | ||
if (in.Band() != lastBand) { | ||
lastBand = in.Band(); | ||
cam->SetBand(icube->physicalBand(lastBand)); | ||
} | ||
|
||
// Loop for each pixel in the line. | ||
double samp, phase, emission, incidence; | ||
double line = in.Line(); | ||
for (int i = 0; i < in.size(); i++) { | ||
samp = in.Sample(i); | ||
cam->SetImage(samp, line); | ||
if (cam->HasSurfaceIntersection()) { | ||
if (((phase = cam->PhaseAngle()) < minPhase) || (phase > maxPhase)) { | ||
out[i] = Isis::NULL8; | ||
} | ||
else if (((emission = cam->EmissionAngle()) < minEmission) || | ||
(emission > maxEmission)) { | ||
out[i] = Isis::NULL8; | ||
} | ||
else if (((incidence = cam->IncidenceAngle()) < minIncidence) || | ||
(incidence > maxIncidence)) { | ||
out[i] = Isis::NULL8; | ||
} | ||
else { | ||
out[i] = in[i]; | ||
} | ||
} | ||
// Trim outerspace | ||
else { | ||
out[i] = Isis::NULL8; | ||
} | ||
} | ||
photrim(ui); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/** 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 "photrim.h" | ||
|
||
#include "Camera.h" | ||
#include "ProcessByLine.h" | ||
#include "SpecialPixel.h" | ||
|
||
namespace Isis { | ||
|
||
/* | ||
* The photrim program trims pixels outside of the phase, incidence, | ||
* and emission angles by setting them to "null" within all bands of | ||
* the cube. A user can either trim using the program's default method | ||
* or the USEDEM method. | ||
* | ||
* @param ui UserInterface object containing parameters | ||
*/ | ||
void photrim(UserInterface &ui) { | ||
|
||
// open input cube | ||
Cube icube; | ||
icube.open(ui.GetCubeName("FROM")); | ||
|
||
photrim(&icube, ui); | ||
} | ||
|
||
|
||
/* | ||
* The photrim program trims pixels outside of the phase, incidence, | ||
* and emission angles by setting them to "null" within all bands of | ||
* the cube. A user can either trim using the program's default method | ||
* or the USEDEM method. | ||
* | ||
* @param iCube Input cube | ||
* @param ui UserInterface object containing parameters | ||
*/ | ||
void photrim(Cube *icube, UserInterface &ui) { | ||
// processing by line | ||
ProcessByLine p; | ||
|
||
// Setup input cube and get the camera model | ||
p.SetInputCube(icube); | ||
|
||
Camera* cam = icube->camera(); | ||
|
||
// Create the output cube | ||
QString fname = ui.GetCubeName("TO"); | ||
CubeAttributeOutput &atts = ui.GetOutputAttribute("TO"); | ||
p.SetOutputCube(fname, atts); | ||
|
||
// Get the trim angles | ||
double minPhase = ui.GetDouble("MINPHASE"); | ||
double maxPhase = ui.GetDouble("MAXPHASE"); | ||
double minEmission = ui.GetDouble("MINEMISSION"); | ||
double maxEmission = ui.GetDouble("MAXEMISSION"); | ||
double minIncidence = ui.GetDouble("MININCIDENCE"); | ||
double maxIncidence = ui.GetDouble("MAXINCIDENCE"); | ||
|
||
bool usedem = ui.GetBoolean("USEDEM"); | ||
|
||
if (!usedem) { | ||
cam->IgnoreElevationModel(true); | ||
} | ||
|
||
// Start the processing | ||
int lastBand = 0; | ||
|
||
// lambda function with captures to process by line | ||
auto photrimLineProcess = [&](Buffer &in, Buffer &out)->void { | ||
// See if there is a change in band which would change the camera model | ||
if (in.Band() != lastBand) { | ||
lastBand = in.Band(); | ||
cam->SetBand(icube->physicalBand(lastBand)); | ||
} | ||
|
||
// Loop for each pixel in the line. | ||
double samp, phase, emission, incidence; | ||
double line = in.Line(); | ||
for (int i = 0; i < in.size(); i++) { | ||
samp = in.Sample(i); | ||
cam->SetImage(samp, line); | ||
if (cam->HasSurfaceIntersection()) { | ||
if (((phase = cam->PhaseAngle()) < minPhase) || (phase > maxPhase)) { | ||
out[i] = Isis::NULL8; | ||
} | ||
else if (((emission = cam->EmissionAngle()) < minEmission) || | ||
(emission > maxEmission)) { | ||
out[i] = Isis::NULL8; | ||
} | ||
else if (((incidence = cam->IncidenceAngle()) < minIncidence) || | ||
(incidence > maxIncidence)) { | ||
out[i] = Isis::NULL8; | ||
} | ||
else { | ||
out[i] = in[i]; | ||
} | ||
} | ||
// Trim outerspace | ||
else { | ||
out[i] = Isis::NULL8; | ||
} | ||
} | ||
}; | ||
|
||
p.StartProcess(photrimLineProcess); | ||
p.EndProcess(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** 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 photrim_h | ||
#define photrim_h | ||
|
||
#include "UserInterface.h" | ||
|
||
namespace Isis{ | ||
extern void photrim(UserInterface &ui); | ||
extern void photrim(Cube *icube, UserInterface &ui); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.