Skip to content

Commit

Permalink
Merge pull request #4938 from blowekamp/fix_orientimagefilter_legacy
Browse files Browse the repository at this point in the history
COMP: Fix OrientImageFilter tests with options
  • Loading branch information
blowekamp authored Nov 8, 2024
2 parents 286996b + 25f7948 commit d2b5ed6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Modules/Filtering/ImageGrid/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ set(ITKImageGridTests
itkPasteImageFilterTest.cxx
itkPermuteAxesImageFilterTest.cxx
itkOrientImageFilterTest.cxx
itkOrientImageFilterTest2.cxx
itkWarpImageFilterTest.cxx
itkWarpImageFilterTest2.cxx
itkWarpVectorImageFilterTest.cxx
Expand All @@ -55,6 +54,11 @@ set(ITKImageGridTests
itkSliceBySliceImageFilterTest.cxx
itkPadImageFilterTest.cxx)

if( NOT ITK_FUTURE_LEGACY_REMOVE)
list(APPEND ITKImageGridTests itkOrientImageFilterTest2.cxx)
endif()


createtestdriver(ITKImageGrid "${ITKImageGrid-Test_LIBRARIES}" "${ITKImageGridTests}")

itk_add_test(
Expand Down
23 changes: 9 additions & 14 deletions Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
*=========================================================================*/

#define ITK_LEGACY_SILENT
#include "itkOrientImageFilter.h"
#include "itkImageToImageFilter.h"
#include "itkTestingMacros.h"
Expand Down Expand Up @@ -83,20 +82,18 @@ itkOrientImageFilterTest(int argc, char * argv[])
auto useImageDirection = static_cast<bool>(std::stoi(argv[1]));
ITK_TEST_SET_GET_BOOLEAN(orienter, UseImageDirection, useImageDirection);

orienter->SetGivenCoordinateOrientation(
itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_RIP);
orienter->SetGivenCoordinateOrientation(itk::AnatomicalOrientation::PositiveEnum::LSA);
orienter->SetInput(randImage);

// Try permuting axes
orienter->SetDesiredCoordinateOrientation(
itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_IRP);
orienter->SetDesiredCoordinateOrientation(itk::AnatomicalOrientation::PositiveEnum::SLA);
orienter->Update();
ImageType::Pointer IRP = orienter->GetOutput();
std::cerr << "IRP" << std::endl;
PrintImg(IRP);
ImageType::Pointer SLA = orienter->GetOutput();
std::cerr << "SLA" << std::endl;
PrintImg(SLA);

ImageType::RegionType::SizeType originalSize = randImage->GetLargestPossibleRegion().GetSize();
ImageType::RegionType::SizeType transformedSize = IRP->GetLargestPossibleRegion().GetSize();
ImageType::RegionType::SizeType transformedSize = SLA->GetLargestPossibleRegion().GetSize();
ImageType::IndexType originalIndex, transformedIndex;

for (originalIndex[2] = transformedIndex[2] = 0;
Expand All @@ -112,7 +109,7 @@ itkOrientImageFilterTest(int argc, char * argv[])
originalIndex[0]++, transformedIndex[1]++)
{
ImageType::PixelType orig = randImage->GetPixel(originalIndex);
ImageType::PixelType xfrm = IRP->GetPixel(transformedIndex);
ImageType::PixelType xfrm = SLA->GetPixel(transformedIndex);
if (orig != xfrm)
{
return EXIT_FAILURE;
Expand All @@ -124,10 +121,8 @@ itkOrientImageFilterTest(int argc, char * argv[])
// Go to LIP to check flipping an axis
orienter = itk::OrientImageFilter<ImageType, ImageType>::New();
orienter->SetInput(randImage);
orienter->SetGivenCoordinateOrientation(
itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_RIP);
orienter->SetDesiredCoordinateOrientation(
itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_LIP);
orienter->SetGivenCoordinateOrientation(itk::AnatomicalOrientation::NegativeEnum::RIP);
orienter->SetDesiredCoordinateOrientation(itk::AnatomicalOrientation::NegativeEnum::LIP);
orienter->Update();
ImageType::Pointer LIP = orienter->GetOutput();
std::cerr << "LIP" << std::endl;
Expand Down

0 comments on commit d2b5ed6

Please sign in to comment.