-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* app conversion * add test data and working test case * move data * compare framelets
- Loading branch information
Showing
10 changed files
with
172 additions
and
72 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** 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 "ProcessImportPds.h" | ||
#include "FileName.h" | ||
#include "Brick.h" | ||
#include "ProcessByBrick.h" | ||
#include "OriginalLabel.h" | ||
#include "IException.h" | ||
#include "marciflip.h" | ||
|
||
using namespace std; | ||
|
||
Isis::Cube *outputCube = NULL; | ||
int currentLine; | ||
int filterHeight = 16; | ||
|
||
void flipCube(Isis::Buffer &data); | ||
|
||
namespace Isis { | ||
|
||
void marciflip(UserInterface &ui) { | ||
|
||
Isis::ProcessByBrick p; | ||
QString cubeFn; | ||
Isis::Cube *icube; | ||
Isis::CubeAttributeInput inAtt; | ||
|
||
cubeFn = ui.GetFileName("FROM"); | ||
icube = new Cube(cubeFn); | ||
inAtt = ui.GetInputAttribute("FROM"); | ||
|
||
p.SetInputCube(cubeFn, inAtt); | ||
|
||
filterHeight = 16 / (int)icube->group("Instrument")["SummingMode"]; | ||
|
||
p.SetBrickSize(icube->sampleCount(), filterHeight, icube->bandCount()); | ||
|
||
currentLine = icube->lineCount(); | ||
|
||
outputCube = new Cube(); | ||
outputCube->setDimensions(icube->sampleCount(), icube->lineCount(), icube->bandCount()); | ||
|
||
outputCube->create(ui.GetFileName("TO")); | ||
|
||
if(icube->hasGroup("Instrument")) { | ||
PvlGroup inst = icube->group("Instrument"); | ||
|
||
// change flipped keyword | ||
inst["DataFlipped"] = toString(((int)inst["DataFlipped"] + 1) % 2); | ||
|
||
outputCube->label()->findObject("IsisCube").addGroup(inst); | ||
} | ||
|
||
if(icube->hasGroup("BandBin")) { | ||
outputCube->label()->findObject("IsisCube").addGroup( | ||
icube->group("BandBin")); | ||
} | ||
|
||
if(icube->label()->hasObject("OriginalLabel")) { | ||
OriginalLabel origLabel = icube->readOriginalLabel(); | ||
outputCube->write(origLabel); | ||
} | ||
|
||
p.StartProcess(flipCube); | ||
p.EndProcess(); | ||
|
||
outputCube->close(); | ||
delete outputCube; | ||
} | ||
} | ||
|
||
void flipCube(Isis::Buffer &data) { | ||
currentLine -= filterHeight; | ||
Isis::Brick outBrick(data.SampleDimension(), data.LineDimension(), data.BandDimension(), data.PixelType()); | ||
outBrick.Copy(data); | ||
outBrick.SetBasePosition(1, currentLine + 1, data.Band()); | ||
outputCube->write(outBrick); | ||
} |
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,18 @@ | ||
#ifndef marciflip_h | ||
#define marciflip_h | ||
|
||
/** 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 "UserInterface.h" | ||
|
||
namespace Isis{ | ||
extern void marciflip(UserInterface &ui); | ||
} | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <QTemporaryDir> | ||
|
||
#include "marciflip.h" | ||
#include "Fixtures.h" | ||
#include "Pvl.h" | ||
#include "PvlGroup.h" | ||
#include "TestUtilities.h" | ||
#include "Histogram.h" | ||
#include "Portal.h" | ||
|
||
#include "gtest/gtest.h" | ||
#include "gmock/gmock.h" | ||
|
||
using namespace Isis; | ||
|
||
static QString APP_XML = FileName("$ISISROOT/bin/xml/marciflip.xml").expanded(); | ||
|
||
TEST(Marciflip, MarciflipTestDefault) { | ||
QTemporaryDir prefix; | ||
QString outCubeFn = prefix.path() + "/marciflip_out.cub"; | ||
QString inCubeFn = "data/marciflip/T02_001002_1200_MC_00N284W_cropped.cub"; | ||
QVector<QString> args = {"from=" + inCubeFn, "to=" + outCubeFn }; | ||
UserInterface options(APP_XML, args); | ||
marciflip(options); | ||
|
||
Cube inCube(inCubeFn); | ||
Cube outCube(outCubeFn); | ||
Pvl *label = outCube.label(); | ||
|
||
PvlGroup &dims = label->findGroup("Dimensions", Pvl::Traverse); | ||
EXPECT_EQ( (int)dims["Lines"], 48 ); | ||
EXPECT_EQ( (int)dims["Samples"], 2 ); | ||
EXPECT_EQ( (int)dims["Bands"], 3 ); | ||
|
||
PvlGroup &inst = label->findGroup("Instrument", Pvl::Traverse); | ||
EXPECT_EQ( (int)inst.findKeyword("DataFlipped"), 0 ); | ||
|
||
// check that the cubes have equal histograms | ||
// since pixels should only be moved, not changed | ||
std::unique_ptr<Histogram> outHist (outCube.histogram()); | ||
std::unique_ptr<Histogram> inHist (inCube.histogram()); | ||
EXPECT_EQ( outHist->Average(), outHist->Average() ); | ||
EXPECT_EQ( outHist->Sum(), outHist->Sum() ); | ||
EXPECT_EQ( outHist->ValidPixels(), outHist->ValidPixels() ); | ||
EXPECT_EQ( outHist->StandardDeviation(), outHist->StandardDeviation() ); | ||
|
||
|
||
// check that first 8 lines of input cube | ||
// are equal to last 8 lines of output cube | ||
Portal iPortal( 2, 1, inCube.pixelType() ); | ||
Portal oPortal( 2, 1, outCube.pixelType() ); | ||
|
||
for( int lines = 0; lines < 8; lines++ ) { | ||
iPortal.SetPosition(1, 1 + lines, 1); | ||
inCube.read(iPortal); | ||
|
||
oPortal.SetPosition(1, 41 + lines, 1); | ||
outCube.read(oPortal); | ||
|
||
EXPECT_DOUBLE_EQ(iPortal[0], oPortal[0]); | ||
EXPECT_DOUBLE_EQ(iPortal[1], oPortal[1]); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
Binary file not shown.