From 37d8fcf8543c1fcfe5d5116577b0f8c5123de9ed Mon Sep 17 00:00:00 2001 From: tgiroux Date: Thu, 29 Apr 2021 09:54:20 -0700 Subject: [PATCH 1/4] app conversion --- isis/src/mro/apps/marciflip/main.cpp | 59 +--------------- isis/src/mro/apps/marciflip/marciflip.cpp | 82 +++++++++++++++++++++++ isis/src/mro/apps/marciflip/marciflip.h | 19 ++++++ isis/tests/FunctionalTestsMarciflip.cpp | 41 ++++++++++++ 4 files changed, 145 insertions(+), 56 deletions(-) create mode 100644 isis/src/mro/apps/marciflip/marciflip.cpp create mode 100644 isis/src/mro/apps/marciflip/marciflip.h create mode 100644 isis/tests/FunctionalTestsMarciflip.cpp diff --git a/isis/src/mro/apps/marciflip/main.cpp b/isis/src/mro/apps/marciflip/main.cpp index 46d7e49695..bb82715d72 100644 --- a/isis/src/mro/apps/marciflip/main.cpp +++ b/isis/src/mro/apps/marciflip/main.cpp @@ -7,66 +7,13 @@ find files of those names at the top level of this repository. **/ /* SPDX-License-Identifier: CC0-1.0 */ #include "Isis.h" -#include "ProcessImportPds.h" -#include "FileName.h" -#include "Brick.h" -#include "ProcessByBrick.h" -#include "OriginalLabel.h" -#include "IException.h" +#include "UserInterface.h" +#include "marciflip.h" using namespace std; using namespace Isis; -Isis::Cube *outputCube = NULL; -int currentLine; -int filterHeight = 16; - -void flipCube(Isis::Buffer &data); - void IsisMain() { - ProcessByBrick p; - - Cube *icube = p.SetInputCube("FROM"); - - filterHeight = 16 / (int)icube->group("Instrument")["SummingMode"]; - p.SetBrickSize(icube->sampleCount(), filterHeight, icube->bandCount()); - currentLine = icube->lineCount(); - UserInterface &ui = Application::GetUserInterface(); - outputCube = new Isis::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; - Brick outBrick(data.SampleDimension(), data.LineDimension(), data.BandDimension(), data.PixelType()); - outBrick.Copy(data); - outBrick.SetBasePosition(1, currentLine + 1, data.Band()); - outputCube->write(outBrick); + marciflip(ui); } diff --git a/isis/src/mro/apps/marciflip/marciflip.cpp b/isis/src/mro/apps/marciflip/marciflip.cpp new file mode 100644 index 0000000000..2369d8942e --- /dev/null +++ b/isis/src/mro/apps/marciflip/marciflip.cpp @@ -0,0 +1,82 @@ +/** 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; +Isis::ProcessByBrick p; +QString cubeFn; +Isis::Cube *icube; +Isis::CubeAttributeInput inAtt; + +namespace Isis { + + void marciflip(UserInterface &ui) { + + 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) { + cout << "flipping data" << endl; + currentLine -= filterHeight; + Brick outBrick(data.SampleDimension(), data.LineDimension(), data.BandDimension(), data.PixelType()); + outBrick.Copy(data); + outBrick.SetBasePosition(1, currentLine + 1, data.Band()); + outputCube->write(outBrick); + } +} \ No newline at end of file diff --git a/isis/src/mro/apps/marciflip/marciflip.h b/isis/src/mro/apps/marciflip/marciflip.h new file mode 100644 index 0000000000..cbe826eb4d --- /dev/null +++ b/isis/src/mro/apps/marciflip/marciflip.h @@ -0,0 +1,19 @@ +#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); + extern void flipCube(Isis::Buffer &data); +} + +#endif diff --git a/isis/tests/FunctionalTestsMarciflip.cpp b/isis/tests/FunctionalTestsMarciflip.cpp new file mode 100644 index 0000000000..550181a024 --- /dev/null +++ b/isis/tests/FunctionalTestsMarciflip.cpp @@ -0,0 +1,41 @@ +#include + +#include "marciflip.h" +#include "Fixtures.h" +#include "Pvl.h" +#include "PvlGroup.h" +#include "TestUtilities.h" +#include "Histogram.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 cubeFileName = prefix.path() + "/marciflip_out.cub"; TODO + QString cubeFileName = "/Users/tgiroux/Desktop/marciflip_out.cub"; + QVector args = {"from=data/marci2isis/K14_059003_3475_MA_00N112W_cropped.cub", "to=" + cubeFileName }; + UserInterface options(APP_XML, args); + marciflip(options); + + Cube outCube(cubeFileName); + Pvl *label = outCube.label(); + + PvlGroup &dims = label->findGroup("Dimensions", Pvl::Traverse); + EXPECT_EQ( (int)dims["Lines"], 2 ); + EXPECT_EQ( (int)dims["Samples"], 50 ); + EXPECT_EQ( (int)dims["Bands"], 5 ); + + PvlGroup &inst = label->findGroup("Instrument", Pvl::Traverse); + EXPECT_EQ( inst["VariableExposureDuration"][0].toStdString(), "8.8" ); + + std::unique_ptr outHist (outCube.histogram()); + EXPECT_NEAR( outHist->Average(), 0.034876, 1e-6 ); + EXPECT_NEAR( outHist->Sum(), 1.39504, 1e-5 ); + EXPECT_EQ( outHist->ValidPixels(), 40 ); + EXPECT_NEAR( outHist->StandardDeviation(), 0.0110666, 1e-7 ); +} \ No newline at end of file From 917be2e2d3f7a68c06b678bfddda19ab427177bb Mon Sep 17 00:00:00 2001 From: tgiroux Date: Thu, 29 Apr 2021 12:22:27 -0700 Subject: [PATCH 2/4] add test data and working test case --- isis/src/mro/apps/marciflip/marciflip.cpp | 30 ++++++++++-------- isis/src/mro/apps/marciflip/marciflip.h | 1 - isis/src/mro/apps/marciflip/tsts/Makefile | 4 --- .../mro/apps/marciflip/tsts/default/Makefile | 8 ----- isis/tests/FunctionalTestsMarciflip.cpp | 22 ++++++------- .../T02_001002_1200_MC_00N284W_cropped.cub | Bin 0 -> 69044 bytes 6 files changed, 27 insertions(+), 38 deletions(-) delete mode 100644 isis/src/mro/apps/marciflip/tsts/Makefile delete mode 100644 isis/src/mro/apps/marciflip/tsts/default/Makefile create mode 100644 isis/tests/data/marci2isis/T02_001002_1200_MC_00N284W_cropped.cub diff --git a/isis/src/mro/apps/marciflip/marciflip.cpp b/isis/src/mro/apps/marciflip/marciflip.cpp index 2369d8942e..98f3231a9f 100644 --- a/isis/src/mro/apps/marciflip/marciflip.cpp +++ b/isis/src/mro/apps/marciflip/marciflip.cpp @@ -19,15 +19,18 @@ using namespace std; Isis::Cube *outputCube = NULL; int currentLine; int filterHeight = 16; -Isis::ProcessByBrick p; -QString cubeFn; -Isis::Cube *icube; -Isis::CubeAttributeInput inAtt; + +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"); @@ -70,13 +73,12 @@ namespace Isis { outputCube->close(); delete outputCube; } - - void flipCube(Isis::Buffer &data) { - cout << "flipping data" << endl; - currentLine -= filterHeight; - Brick outBrick(data.SampleDimension(), data.LineDimension(), data.BandDimension(), data.PixelType()); - outBrick.Copy(data); - outBrick.SetBasePosition(1, currentLine + 1, data.Band()); - outputCube->write(outBrick); - } -} \ No newline at end of file +} + +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); +} diff --git a/isis/src/mro/apps/marciflip/marciflip.h b/isis/src/mro/apps/marciflip/marciflip.h index cbe826eb4d..f542d55bac 100644 --- a/isis/src/mro/apps/marciflip/marciflip.h +++ b/isis/src/mro/apps/marciflip/marciflip.h @@ -13,7 +13,6 @@ find files of those names at the top level of this repository. **/ namespace Isis{ extern void marciflip(UserInterface &ui); - extern void flipCube(Isis::Buffer &data); } #endif diff --git a/isis/src/mro/apps/marciflip/tsts/Makefile b/isis/src/mro/apps/marciflip/tsts/Makefile deleted file mode 100644 index 46d84c74c2..0000000000 --- a/isis/src/mro/apps/marciflip/tsts/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -BLANKS = "%-6s" -LENGTH = "%-40s" - -include $(ISISROOT)/make/isismake.tststree diff --git a/isis/src/mro/apps/marciflip/tsts/default/Makefile b/isis/src/mro/apps/marciflip/tsts/default/Makefile deleted file mode 100644 index cc0f7ebfb4..0000000000 --- a/isis/src/mro/apps/marciflip/tsts/default/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -APPNAME = marciflip - -include $(ISISROOT)/make/isismake.tsts - -commands: - $(APPNAME) FROM=$(INPUT)/T02_001002_1200_MC_00N284W.cub \ - TO=$(OUTPUT)/flipped.cub > /dev/null; - catlab FROM=$(OUTPUT)/flipped.cub to=$(OUTPUT)/flipped.pvl > /dev/null; diff --git a/isis/tests/FunctionalTestsMarciflip.cpp b/isis/tests/FunctionalTestsMarciflip.cpp index 550181a024..58c4937ad6 100644 --- a/isis/tests/FunctionalTestsMarciflip.cpp +++ b/isis/tests/FunctionalTestsMarciflip.cpp @@ -16,9 +16,8 @@ static QString APP_XML = FileName("$ISISROOT/bin/xml/marciflip.xml").expanded(); TEST(Marciflip, MarciflipTestDefault) { QTemporaryDir prefix; - //QString cubeFileName = prefix.path() + "/marciflip_out.cub"; TODO - QString cubeFileName = "/Users/tgiroux/Desktop/marciflip_out.cub"; - QVector args = {"from=data/marci2isis/K14_059003_3475_MA_00N112W_cropped.cub", "to=" + cubeFileName }; + QString cubeFileName = prefix.path() + "/marciflip_out.cub"; + QVector args = {"from=data/marci2isis/T02_001002_1200_MC_00N284W_cropped.cub", "to=" + cubeFileName }; UserInterface options(APP_XML, args); marciflip(options); @@ -26,16 +25,17 @@ TEST(Marciflip, MarciflipTestDefault) { Pvl *label = outCube.label(); PvlGroup &dims = label->findGroup("Dimensions", Pvl::Traverse); - EXPECT_EQ( (int)dims["Lines"], 2 ); - EXPECT_EQ( (int)dims["Samples"], 50 ); - EXPECT_EQ( (int)dims["Bands"], 5 ); + 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( inst["VariableExposureDuration"][0].toStdString(), "8.8" ); + EXPECT_EQ( (int)inst.findKeyword("DataFlipped"), 0 ); std::unique_ptr outHist (outCube.histogram()); - EXPECT_NEAR( outHist->Average(), 0.034876, 1e-6 ); - EXPECT_NEAR( outHist->Sum(), 1.39504, 1e-5 ); - EXPECT_EQ( outHist->ValidPixels(), 40 ); - EXPECT_NEAR( outHist->StandardDeviation(), 0.0110666, 1e-7 ); + EXPECT_NEAR( outHist->Average(), 50.552, 1e-3 ); + EXPECT_NEAR( outHist->Sum(), 4853, 1 ); + EXPECT_EQ( outHist->ValidPixels(), 96 ); + EXPECT_NEAR( outHist->StandardDeviation(), 11.63829, 1e-5 ); + } \ No newline at end of file diff --git a/isis/tests/data/marci2isis/T02_001002_1200_MC_00N284W_cropped.cub b/isis/tests/data/marci2isis/T02_001002_1200_MC_00N284W_cropped.cub new file mode 100644 index 0000000000000000000000000000000000000000..4619ec224edf6290850436fe7d194f387f75bfae GIT binary patch literal 69044 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 literal 0 HcmV?d00001 From 85488bcca5e544e85f3f99b3d1daeeb27899e968 Mon Sep 17 00:00:00 2001 From: tgiroux Date: Thu, 29 Apr 2021 12:33:22 -0700 Subject: [PATCH 3/4] move data --- isis/tests/FunctionalTestsMarcical.cpp | 8 ++++---- isis/tests/FunctionalTestsMarciflip.cpp | 2 +- .../K14_059003_3475_MA_00N112W_cropped.cub | 0 .../P12_005901_3391_MA_00N096W_cropped.cub | 0 .../T02_001002_1200_MC_00N284W_cropped.cub | Bin 5 files changed, 5 insertions(+), 5 deletions(-) rename isis/tests/data/{marci2isis => marcical}/K14_059003_3475_MA_00N112W_cropped.cub (100%) rename isis/tests/data/{marci2isis => marcical}/P12_005901_3391_MA_00N096W_cropped.cub (100%) rename isis/tests/data/{marci2isis => marciflip}/T02_001002_1200_MC_00N284W_cropped.cub (100%) diff --git a/isis/tests/FunctionalTestsMarcical.cpp b/isis/tests/FunctionalTestsMarcical.cpp index 5676375af8..7338f781b1 100644 --- a/isis/tests/FunctionalTestsMarcical.cpp +++ b/isis/tests/FunctionalTestsMarcical.cpp @@ -17,7 +17,7 @@ static QString APP_XML = FileName("$ISISROOT/bin/xml/marcical.xml").expanded(); TEST(Marcical, MarcicalTestDefault) { QTemporaryDir prefix; QString cubeFileName = prefix.path() + "/marcical_out.cub"; - QVector args = {"from=data/marci2isis/P12_005901_3391_MA_00N096W_cropped.cub", "to=" + cubeFileName }; + QVector args = {"from=data/marcical/P12_005901_3391_MA_00N096W_cropped.cub", "to=" + cubeFileName }; UserInterface options(APP_XML, args); marcical(options); @@ -44,7 +44,7 @@ TEST(Marcical, MarcicalTestDefault) { TEST(Marcical, MarcicalTestDefaultNoIof) { QTemporaryDir prefix; QString cubeFileName = prefix.path() + "/marcical_out.cub"; - QVector args = {"from=data/marci2isis/P12_005901_3391_MA_00N096W_cropped.cub", "to=" + cubeFileName, "iof=no" }; + QVector args = {"from=data/marcical/P12_005901_3391_MA_00N096W_cropped.cub", "to=" + cubeFileName, "iof=no" }; UserInterface options(APP_XML, args); marcical(options); @@ -71,7 +71,7 @@ TEST(Marcical, MarcicalTestDefaultNoIof) { TEST(Marcical, MarcicalTestSingleDuration) { QTemporaryDir prefix; QString cubeFileName = prefix.path() + "/marcical_out.cub"; - QVector args = {"from=data/marci2isis/K14_059003_3475_MA_00N112W_cropped.cub", "to=" + cubeFileName }; + QVector args = {"from=data/marcical/K14_059003_3475_MA_00N112W_cropped.cub", "to=" + cubeFileName }; UserInterface options(APP_XML, args); marcical(options); @@ -96,7 +96,7 @@ TEST(Marcical, MarcicalTestSingleDuration) { TEST(Marcical, MarcicalTestSingleDurationNoIof) { QTemporaryDir prefix; QString cubeFileName = prefix.path() + "/marcical_out.cub"; - QVector args = {"from=data/marci2isis/K14_059003_3475_MA_00N112W_cropped.cub", "to=" + cubeFileName, "iof=no" }; + QVector args = {"from=data/marcical/K14_059003_3475_MA_00N112W_cropped.cub", "to=" + cubeFileName, "iof=no" }; UserInterface options(APP_XML, args); marcical(options); diff --git a/isis/tests/FunctionalTestsMarciflip.cpp b/isis/tests/FunctionalTestsMarciflip.cpp index 58c4937ad6..ded47fbd07 100644 --- a/isis/tests/FunctionalTestsMarciflip.cpp +++ b/isis/tests/FunctionalTestsMarciflip.cpp @@ -17,7 +17,7 @@ static QString APP_XML = FileName("$ISISROOT/bin/xml/marciflip.xml").expanded(); TEST(Marciflip, MarciflipTestDefault) { QTemporaryDir prefix; QString cubeFileName = prefix.path() + "/marciflip_out.cub"; - QVector args = {"from=data/marci2isis/T02_001002_1200_MC_00N284W_cropped.cub", "to=" + cubeFileName }; + QVector args = {"from=data/marciflip/T02_001002_1200_MC_00N284W_cropped.cub", "to=" + cubeFileName }; UserInterface options(APP_XML, args); marciflip(options); diff --git a/isis/tests/data/marci2isis/K14_059003_3475_MA_00N112W_cropped.cub b/isis/tests/data/marcical/K14_059003_3475_MA_00N112W_cropped.cub similarity index 100% rename from isis/tests/data/marci2isis/K14_059003_3475_MA_00N112W_cropped.cub rename to isis/tests/data/marcical/K14_059003_3475_MA_00N112W_cropped.cub diff --git a/isis/tests/data/marci2isis/P12_005901_3391_MA_00N096W_cropped.cub b/isis/tests/data/marcical/P12_005901_3391_MA_00N096W_cropped.cub similarity index 100% rename from isis/tests/data/marci2isis/P12_005901_3391_MA_00N096W_cropped.cub rename to isis/tests/data/marcical/P12_005901_3391_MA_00N096W_cropped.cub diff --git a/isis/tests/data/marci2isis/T02_001002_1200_MC_00N284W_cropped.cub b/isis/tests/data/marciflip/T02_001002_1200_MC_00N284W_cropped.cub similarity index 100% rename from isis/tests/data/marci2isis/T02_001002_1200_MC_00N284W_cropped.cub rename to isis/tests/data/marciflip/T02_001002_1200_MC_00N284W_cropped.cub From b10635a86cf55fd9f04395ef119867f8d26aaef9 Mon Sep 17 00:00:00 2001 From: tgiroux Date: Wed, 12 May 2021 09:58:17 -0700 Subject: [PATCH 4/4] compare framelets --- isis/tests/FunctionalTestsMarciflip.cpp | 38 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/isis/tests/FunctionalTestsMarciflip.cpp b/isis/tests/FunctionalTestsMarciflip.cpp index ded47fbd07..41d7c830f9 100644 --- a/isis/tests/FunctionalTestsMarciflip.cpp +++ b/isis/tests/FunctionalTestsMarciflip.cpp @@ -6,6 +6,7 @@ #include "PvlGroup.h" #include "TestUtilities.h" #include "Histogram.h" +#include "Portal.h" #include "gtest/gtest.h" #include "gmock/gmock.h" @@ -16,12 +17,14 @@ static QString APP_XML = FileName("$ISISROOT/bin/xml/marciflip.xml").expanded(); TEST(Marciflip, MarciflipTestDefault) { QTemporaryDir prefix; - QString cubeFileName = prefix.path() + "/marciflip_out.cub"; - QVector args = {"from=data/marciflip/T02_001002_1200_MC_00N284W_cropped.cub", "to=" + cubeFileName }; + QString outCubeFn = prefix.path() + "/marciflip_out.cub"; + QString inCubeFn = "data/marciflip/T02_001002_1200_MC_00N284W_cropped.cub"; + QVector args = {"from=" + inCubeFn, "to=" + outCubeFn }; UserInterface options(APP_XML, args); marciflip(options); - Cube outCube(cubeFileName); + Cube inCube(inCubeFn); + Cube outCube(outCubeFn); Pvl *label = outCube.label(); PvlGroup &dims = label->findGroup("Dimensions", Pvl::Traverse); @@ -32,10 +35,29 @@ TEST(Marciflip, MarciflipTestDefault) { 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 outHist (outCube.histogram()); - EXPECT_NEAR( outHist->Average(), 50.552, 1e-3 ); - EXPECT_NEAR( outHist->Sum(), 4853, 1 ); - EXPECT_EQ( outHist->ValidPixels(), 96 ); - EXPECT_NEAR( outHist->StandardDeviation(), 11.63829, 1e-5 ); + std::unique_ptr 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() ); -} \ No newline at end of file + + // 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]); + } +}