diff --git a/Examples/Filtering/CMakeLists.txt b/Examples/Filtering/CMakeLists.txt index 0fabad39d80..4d9936c84d9 100644 --- a/Examples/Filtering/CMakeLists.txt +++ b/Examples/Filtering/CMakeLists.txt @@ -62,8 +62,6 @@ add_executable(RGBToGrayscale RGBToGrayscale.cxx) target_link_libraries(RGBToGrayscale ${ITK_LIBRARIES}) add_executable(BilateralImageFilter BilateralImageFilter.cxx) target_link_libraries(BilateralImageFilter ${ITK_LIBRARIES}) -add_executable(ResampleOrientedImageFilter ResampleOrientedImageFilter.cxx) -target_link_libraries(ResampleOrientedImageFilter ${ITK_LIBRARIES}) add_executable(ResampleImageFilter2 ResampleImageFilter2.cxx) target_link_libraries(ResampleImageFilter2 ${ITK_LIBRARIES}) add_executable(GradientAnisotropicDiffusionImageFilter GradientAnisotropicDiffusionImageFilter.cxx) diff --git a/Examples/Filtering/ResampleOrientedImageFilter.cxx b/Examples/Filtering/ResampleOrientedImageFilter.cxx deleted file mode 100644 index afe48bf362b..00000000000 --- a/Examples/Filtering/ResampleOrientedImageFilter.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkImage.h" -#include "itkImageFileReader.h" -#include "itkImageFileWriter.h" -#include "itkMatrix.h" - -#include "itkResampleImageFilter.h" - -int -main(int argc, char * argv[]) -{ - if (argc < 7) - { - std::cerr << "Usage: " << std::endl; - std::cerr << argv[0] << " inputImageFile outputImageFile"; - std::cerr << " direction cosines" << std::endl; - return EXIT_FAILURE; - } - - constexpr unsigned int Dimension = 2; - using InputPixelType = unsigned char; - using OutputPixelType = unsigned char; - using InputImageType = itk::Image; - using OutputImageType = itk::Image; - - using ReaderType = itk::ImageFileReader; - using WriterType = itk::ImageFileWriter; - - auto reader = ReaderType::New(); - auto writer = WriterType::New(); - - reader->SetFileName(argv[1]); - writer->SetFileName(argv[2]); - - - using FilterType = - itk::ResampleImageFilter; - auto filter = FilterType::New(); - - filter->SetDefaultPixelValue(0); - - { - // pixel spacing in millimeters - const double spacing[Dimension] = { 1.0, 1.0 }; - filter->SetOutputSpacing(spacing); - } - - { - // space coordinate of origin - const double origin[Dimension] = { 0.0, 0.0 }; - filter->SetOutputOrigin(origin); - } - - OutputImageType::DirectionType direction; - direction(0, 0) = std::stoi(argv[3]); - direction(1, 0) = std::stoi(argv[4]); - direction(0, 1) = std::stoi(argv[5]); - direction(1, 1) = std::stoi(argv[6]); - filter->SetOutputDirection(direction); - - InputImageType::SizeType size; - size[0] = 300; // number of pixels along X - size[1] = 300; // number of pixels along Y - - filter->SetSize(size); - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); - writer->Update(); - - return EXIT_SUCCESS; -} diff --git a/Examples/Filtering/test/CMakeLists.txt b/Examples/Filtering/test/CMakeLists.txt index 2d09db0f6a6..2c492468fdb 100644 --- a/Examples/Filtering/test/CMakeLists.txt +++ b/Examples/Filtering/test/CMakeLists.txt @@ -397,21 +397,6 @@ itk_add_test( ${ITK_SOURCE_DIR}/Examples/Data/BrainProtonDensitySlice.png ${TEMP}/ResampleImageFilterTest1.png 0) -itk_add_test( - NAME - ResampleOrientedImageFilterTest - COMMAND - ${ITK_TEST_DRIVER} - --compare - DATA{${BASELINE}/ResampleOrientedImageFilterTest.png} - ${TEMP}/ResampleOrientedImageFilterTest.png - $ - ${ITK_SOURCE_DIR}/Examples/Data/VisibleWomanHeadSlice.png - ${TEMP}/ResampleOrientedImageFilterTest.png - 0 - 1 - 1 - 0) itk_add_test( NAME ResampleImageFilterTest2 diff --git a/Modules/Filtering/ImageGrid/test/CMakeLists.txt b/Modules/Filtering/ImageGrid/test/CMakeLists.txt index aa14d2efee8..9abaac48944 100644 --- a/Modules/Filtering/ImageGrid/test/CMakeLists.txt +++ b/Modules/Filtering/ImageGrid/test/CMakeLists.txt @@ -30,12 +30,6 @@ set(ITKImageGridTests itkInterpolateImageFilterTest.cxx itkPasteImageFilterTest.cxx itkPermuteAxesImageFilterTest.cxx - itkOrientedImage2DTest.cxx - itkOrientedImage3DTest.cxx - itkOrientedImageAdaptorTest.cxx - itkOrientedImageProfileTest1.cxx - itkOrientedImageProfileTest2.cxx - itkOrientedImageProfileTest3.cxx itkOrientImageFilterTest.cxx itkOrientImageFilterTest2.cxx itkWarpImageFilterTest.cxx @@ -392,85 +386,6 @@ itk_add_test( COMMAND ITKImageGridTestDriver itkPermuteAxesImageFilterTest) -itk_add_test( - NAME - itkOrientedImage2DTest01 - COMMAND - ITKImageGridTestDriver - itkOrientedImage2DTest - ${ITK_EXAMPLE_DATA_ROOT}/BrainProtonDensitySliceBorder20DirectionPlus30.mhd - 0.000 - 0.000 - 191.392 - 110.500 - -128.500 - 222.569 - 4.000 - -8.000 - 7.4641 - -4.9282) -itk_add_test( - NAME - itkOrientedImage3DTest01 - COMMAND - ITKImageGridTestDriver - itkOrientedImage3DTest - DATA{${ITK_DATA_ROOT}/Input/HeadMRVolumeWithDirection.mhd} - 0.000 - 0.000 - 0.000 - 166.277 - -96.000 - 0.000 - 124.000 - 214.774 - 0.000 - 0.000 - 0.000 - 168.000 - 0.125 - -4.125 - 9.000 - -1.95425 - -3.63485 - 9.000) -itk_add_test( - NAME - itkOrientedImageAdaptorTest - COMMAND - ITKImageGridTestDriver - itkOrientedImageAdaptorTest) -itk_add_test( - NAME - itkOrientedImageProfileTest1 - COMMAND - ITKImageGridTestDriver - itkOrientedImageProfileTest1) -itk_add_test( - NAME - itkOrientedImageProfileTest2 - COMMAND - ITKImageGridTestDriver - itkOrientedImageProfileTest2) -itk_add_test( - NAME - itkOrientedImageProfileTest3 - COMMAND - ITKImageGridTestDriver - itkOrientedImageProfileTest3) -itk_add_test( - NAME - itkOrientImageFilterTest - COMMAND - ITKImageGridTestDriver - itkOrientImageFilterTest - 0) -itk_add_test( - NAME - itkOrientImageFilterTest2 - COMMAND - ITKImageGridTestDriver - itkOrientImageFilterTest2) itk_add_test( NAME itkWarpImageFilterTest diff --git a/Modules/Filtering/ImageGrid/test/itkOrientedImage2DTest.cxx b/Modules/Filtering/ImageGrid/test/itkOrientedImage2DTest.cxx deleted file mode 100644 index 3bf0d90e887..00000000000 --- a/Modules/Filtering/ImageGrid/test/itkOrientedImage2DTest.cxx +++ /dev/null @@ -1,183 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkImageFileReader.h" -#include "itkCentralDifferenceImageFunction.h" -#include "itkTestingMacros.h" - -int -itkOrientedImage2DTest(int argc, char * argv[]) -{ - - if (argc < 12) - { - std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " InputImage " - << "corner1x corner1y " - << "corner2x corner2y " - << "corner3x corner3y " - << "derivative1x derivative1y " - << "derivative2x derivative2y " << std::endl; - return EXIT_FAILURE; - } - - constexpr unsigned int Dimension = 2; - using PixelType = unsigned char; - - using ImageType = itk::Image; - using ReaderType = itk::ImageFileReader; - - using IndexType = ImageType::IndexType; - using PointType = ImageType::PointType; - using IndexValueType = IndexType::IndexValueType; - - auto reader = ReaderType::New(); - - reader->SetFileName(argv[1]); - - try - { - reader->Update(); - } - catch (const itk::ExceptionObject & e) - { - std::cerr << e << std::endl; - return EXIT_FAILURE; - } - - ImageType::ConstPointer image = reader->GetOutput(); - - ImageType::DirectionType directionCosines = image->GetDirection(); - - std::cout << directionCosines << std::endl; - - unsigned int element = 2; - const double tolerance = 1e-3; - - ImageType::RegionType region = image->GetLargestPossibleRegion(); - ImageType::SizeType size = region.GetSize(); - - constexpr int numberOfPointsToTest = 3; - - IndexType index[numberOfPointsToTest]; - PointType physicalPoint; - - index[0][0] = 0; - index[0][1] = 0; - - index[1][0] = size[0]; - index[1][1] = 0; - - index[2][0] = 0; - index[2][1] = size[1]; - - image->Print(std::cout); - std::cout << std::endl; - std::cout << std::endl; - - for (int pointId = 0; pointId < numberOfPointsToTest; ++pointId) - { - - image->TransformIndexToPhysicalPoint(index[pointId], physicalPoint); - - std::cout << index[pointId] << " : " << physicalPoint << std::endl; - - for (unsigned int dim = 0; dim < Dimension; ++dim) - { - const double expectedValue = std::stod(argv[element++]); - const double currentValue = physicalPoint[dim]; - const double difference = currentValue - expectedValue; - if (itk::Math::abs(difference) > tolerance) - { - std::cerr << "Error: " << std::endl; - std::cerr << "in Point # " << pointId << std::endl; - std::cerr << "Expected = " << expectedValue << std::endl; - std::cerr << "Read = " << currentValue << std::endl; - std::cerr << "Index = " << index[pointId] << std::endl; - std::cerr << "PhysicalPoint = " << physicalPoint << std::endl; - return EXIT_FAILURE; - } - } - } - - // - // Select a point in the middle of the image and compute its - // derivative using the image orientation. - // - IndexType centralIndex; - centralIndex[0] = static_cast(size[0] / 2.0); - centralIndex[1] = static_cast(size[1] / 2.0); - - using CentralDifferenceImageFunctionType = itk::CentralDifferenceImageFunction; - - auto gradientHelper1 = CentralDifferenceImageFunctionType::New(); - gradientHelper1->SetInputImage(image); - - std::cout << std::endl; - std::cout << std::endl; - std::cout << "Image Direction" << std::endl; - std::cout << image->GetDirection() << std::endl; - - { // Compute gradient value without taking image direction into account - gradientHelper1->UseImageDirectionOff(); - CentralDifferenceImageFunctionType::OutputType gradient1a = gradientHelper1->EvaluateAtIndex(centralIndex); - - std::cout << "Gradient without Direction" << std::endl; - std::cout << gradient1a << std::endl; - - for (unsigned int dim = 0; dim < Dimension; ++dim) - { - const double expectedValue = std::stod(argv[element++]); - const double currentValue = gradient1a[dim]; - const double difference = currentValue - expectedValue; - if (itk::Math::abs(difference) > tolerance) - { - std::cerr << "Error: " << std::endl; - - std::cerr << "Expected = " << expectedValue << std::endl; - std::cerr << "Read = " << currentValue << std::endl; - return EXIT_FAILURE; - } - } - } - - - { // Compute gradient value taking image direction into account - gradientHelper1->UseImageDirectionOn(); - CentralDifferenceImageFunctionType::OutputType gradient1b = gradientHelper1->EvaluateAtIndex(centralIndex); - - std::cout << std::endl; - std::cout << "Gradient with Direction" << std::endl; - std::cout << gradient1b << std::endl; - - for (unsigned int dim = 0; dim < Dimension; ++dim) - { - const double expectedValue = std::stod(argv[element++]); - const double currentValue = gradient1b[dim]; - const double difference = currentValue - expectedValue; - if (itk::Math::abs(difference) > tolerance) - { - std::cerr << "Error: " << std::endl; - std::cerr << "Expected = " << expectedValue << std::endl; - std::cerr << "Read = " << currentValue << std::endl; - return EXIT_FAILURE; - } - } - } - - return EXIT_SUCCESS; -} diff --git a/Modules/Filtering/ImageGrid/test/itkOrientedImage3DTest.cxx b/Modules/Filtering/ImageGrid/test/itkOrientedImage3DTest.cxx deleted file mode 100644 index 50a2feba6e0..00000000000 --- a/Modules/Filtering/ImageGrid/test/itkOrientedImage3DTest.cxx +++ /dev/null @@ -1,191 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkImageFileReader.h" -#include "itkCentralDifferenceImageFunction.h" -#include "itkTestingMacros.h" - -int -itkOrientedImage3DTest(int argc, char * argv[]) -{ - - if (argc < 20) - { - std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " InputImage " - << "corner1x corner1y corner1z " - << "corner2x corner2y corner2z " - << "corner3x corner3y corner3z " - << "corner4x corner4y corner4z " - << "derivative1x derivative1y derivative1z " - << "derivative2x derivative2y derivative2z" << std::endl; - return EXIT_FAILURE; - } - - constexpr unsigned int Dimension = 3; - using PixelType = unsigned char; - - using ImageType = itk::Image; - using ReaderType = itk::ImageFileReader; - - using IndexType = ImageType::IndexType; - using IndexValueType = IndexType::IndexValueType; - - auto reader = ReaderType::New(); - - reader->SetFileName(argv[1]); - - try - { - reader->Update(); - } - catch (const itk::ExceptionObject & e) - { - std::cerr << e << std::endl; - return EXIT_FAILURE; - } - - ImageType::ConstPointer image = reader->GetOutput(); - - ImageType::DirectionType directionCosines = image->GetDirection(); - - std::cout << directionCosines << std::endl; - - unsigned int element = 2; - const double tolerance = 1e-3; - - ImageType::RegionType region = image->GetLargestPossibleRegion(); - ImageType::SizeType size = region.GetSize(); - - constexpr int numberOfPointsToTest = 4; - - ImageType::IndexType index[numberOfPointsToTest]; - ImageType::PointType physicalPoint; - - index[0][0] = 0; - index[0][1] = 0; - index[0][2] = 0; - - index[1][0] = size[0]; - index[1][1] = 0; - index[1][2] = 0; - - index[2][0] = 0; - index[2][1] = size[1]; - index[2][2] = 0; - - index[3][0] = 0; - index[3][1] = 0; - index[3][2] = size[2]; - - - image->Print(std::cout); - std::cout << std::endl; - std::cout << std::endl; - - for (int pointId = 0; pointId < numberOfPointsToTest; ++pointId) - { - - image->TransformIndexToPhysicalPoint(index[pointId], physicalPoint); - - std::cout << index[pointId] << " : " << physicalPoint << std::endl; - - for (unsigned int dim = 0; dim < Dimension; ++dim) - { - const double expectedValue = std::stod(argv[element++]); - const double currentValue = physicalPoint[dim]; - const double difference = currentValue - expectedValue; - if (itk::Math::abs(difference) > tolerance) - { - std::cerr << "Error: " << std::endl; - std::cerr << "in Point # " << pointId << std::endl; - std::cerr << "Expected = " << expectedValue << std::endl; - std::cerr << "Read = " << currentValue << std::endl; - std::cerr << "Index = " << index[pointId] << std::endl; - std::cerr << "PhysicalPoint = " << physicalPoint << std::endl; - } - } - } - - // - // Select a point in the middle of the image and compute its - // derivative using the image orientation. - // - IndexType centralIndex; - centralIndex[0] = static_cast(size[0] / 2.0); - centralIndex[1] = static_cast(size[1] / 2.0); - centralIndex[2] = static_cast(size[2] / 2.0); - - using CentralDifferenceImageFunctionType = itk::CentralDifferenceImageFunction; - - auto gradientHelper1 = CentralDifferenceImageFunctionType::New(); - gradientHelper1->SetInputImage(image); - - std::cout << std::endl; - std::cout << std::endl; - std::cout << "Image Direction" << std::endl; - std::cout << image->GetDirection() << std::endl; - - { // Compute gradient value without taking image direction into account - gradientHelper1->UseImageDirectionOff(); - CentralDifferenceImageFunctionType::OutputType gradient1a = gradientHelper1->EvaluateAtIndex(centralIndex); - - std::cout << "Gradient without Direction" << std::endl; - std::cout << gradient1a << std::endl; - - for (unsigned int dim = 0; dim < Dimension; ++dim) - { - const double expectedValue = std::stod(argv[element++]); - const double currentValue = gradient1a[dim]; - const double difference = currentValue - expectedValue; - if (itk::Math::abs(difference) > tolerance) - { - std::cerr << "Error: " << std::endl; - - std::cerr << "Expected = " << expectedValue << std::endl; - std::cerr << "Read = " << currentValue << std::endl; - return EXIT_FAILURE; - } - } - } - - - { // Compute gradient value taking image direction into account - gradientHelper1->UseImageDirectionOn(); - CentralDifferenceImageFunctionType::OutputType gradient1b = gradientHelper1->EvaluateAtIndex(centralIndex); - - std::cout << std::endl; - std::cout << "Gradient with Direction" << std::endl; - std::cout << gradient1b << std::endl; - - for (unsigned int dim = 0; dim < Dimension; ++dim) - { - const double expectedValue = std::stod(argv[element++]); - const double currentValue = gradient1b[dim]; - const double difference = currentValue - expectedValue; - if (itk::Math::abs(difference) > tolerance) - { - std::cerr << "Error: " << std::endl; - std::cerr << "Expected = " << expectedValue << std::endl; - std::cerr << "Read = " << currentValue << std::endl; - return EXIT_FAILURE; - } - } - } - - return EXIT_SUCCESS; -} diff --git a/Modules/Filtering/ImageGrid/test/itkOrientedImageAdaptorTest.cxx b/Modules/Filtering/ImageGrid/test/itkOrientedImageAdaptorTest.cxx deleted file mode 100644 index 6e7eefdb541..00000000000 --- a/Modules/Filtering/ImageGrid/test/itkOrientedImageAdaptorTest.cxx +++ /dev/null @@ -1,280 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -/** - * - * This program illustrates the use of Adaptors and - * Accessors - * - * The example shows how an Adaptor can be used to - * get access only to the red component of an RGBPixel image - * giving the appearance of being just a 'float' image - * - * That will allow to pass the red component of this - * image as input or output to any filter that expects - * a float image - * - */ - -#include "itkImageAdaptor.h" -#include "itkImageRegionIteratorWithIndex.h" -#include "itkRedPixelAccessor.h" - - -//------------------------------------- -// Typedefs for convenience -//------------------------------------- -using myImageType = itk::Image, 2>; - - -using myRedAccessorType = itk::RedPixelAccessor; - -using myRedAdaptorType = itk::ImageAdaptor; - -using myIteratorType = itk::ImageRegionIteratorWithIndex; - -using myRedIteratorType = itk::ImageRegionIteratorWithIndex; - -//------------------------- -// -// Main code -// -//------------------------- -int -itkOrientedImageAdaptorTest(int, char *[]) -{ - - - myImageType::SizeType size; - size[0] = 2; - size[1] = 2; - - myImageType::IndexType index; - index[0] = 0; - index[1] = 0; - - myImageType::RegionType region{ index, size }; - - auto myImage = myImageType::New(); - - - myImage->SetRegions(region); - myImage->Allocate(); - - myIteratorType it1(myImage, myImage->GetRequestedRegion()); - - // Value to initialize the pixels - myImageType::PixelType::ComponentType colorInit[3] = { 1.0f, 0.5f, 0.5f }; - myImageType::PixelType color = colorInit; - - // Initializing all the pixel in the image - it1.GoToBegin(); - while (!it1.IsAtEnd()) - { - it1.Set(color); - ++it1; - } - - // Reading the values to verify the image content - std::cout << "--- Before --- " << std::endl; - it1.GoToBegin(); - while (!it1.IsAtEnd()) - { - const myImageType::PixelType c(it1.Get()); - std::cout << c.GetRed() << " "; - std::cout << c.GetGreen() << " "; - std::cout << c.GetBlue() << std::endl; - ++it1; - } - - auto myAdaptor = myRedAdaptorType::New(); - myAdaptor->SetImage(myImage); - - - myRedIteratorType it2(myAdaptor, myAdaptor->GetRequestedRegion()); - - // Set the values of the Red component of myImage, using myAdaptor - it2.GoToBegin(); - while (!it2.IsAtEnd()) - { - it2.Set(0.4); - ++it2; - } - - - std::cout << "--- After --- " << std::endl; - - it1.GoToBegin(); - while (!it1.IsAtEnd()) - { - const myImageType::PixelType c(it1.Get()); - std::cout << c.GetRed() << " "; - std::cout << c.GetGreen() << " "; - std::cout << c.GetBlue() << std::endl; - ++it1; - } - - // Test the Set/Get Methods of the adaptor - // First test the get methods of the adaptor - - if (myImage->GetPixelContainer() != myAdaptor->GetPixelContainer()) - { - std::cout << "image pixel container != adaptor pixel container: " << myImage->GetPixelContainer() - << " != " << myAdaptor->GetPixelContainer() << std::endl; - return EXIT_FAILURE; - } - - float forigin[2] = { 2.0, 3.0 }; - myImage->SetOrigin(forigin); - if (myImage->GetOrigin() != myAdaptor->GetOrigin()) - { - std::cout << "image origin != adaptor origin: " << myImage->GetOrigin() << " != " << myAdaptor->GetOrigin() - << std::endl; - return EXIT_FAILURE; - } - - double dorigin[2] = { 2.0, 3.0 }; - myImage->SetOrigin(dorigin); - if (myImage->GetOrigin() != myAdaptor->GetOrigin()) - { - std::cout << "image origin != adaptor origin: " << myImage->GetOrigin() << " != " << myAdaptor->GetOrigin() - << std::endl; - return EXIT_FAILURE; - } - - - myImageType::PointType imageOrigin; - imageOrigin.Fill(10.0); - myImage->SetOrigin(imageOrigin); - if (myImage->GetOrigin() != myAdaptor->GetOrigin()) - { - std::cout << "image origin != adaptor origin: " << myImage->GetOrigin() << " != " << myAdaptor->GetOrigin() - << std::endl; - return EXIT_FAILURE; - } - - float fspacing[2] = { 2.0, 3.0 }; - myImage->SetSpacing(fspacing); - if (myImage->GetSpacing() != myAdaptor->GetSpacing()) - { - std::cout << "image spacing != adaptor spacing: " << myImage->GetSpacing() << " != " << myAdaptor->GetSpacing() - << std::endl; - return EXIT_FAILURE; - } - - double dspacing[2] = { 2.0, 3.0 }; - myImage->SetSpacing(dspacing); - if (myImage->GetSpacing() != myAdaptor->GetSpacing()) - { - std::cout << "image spacing != adaptor spacing: " << myImage->GetSpacing() << " != " << myAdaptor->GetSpacing() - << std::endl; - return EXIT_FAILURE; - } - - - myImageType::SpacingType imageSpacing; - imageSpacing.Fill(10.0); - - myImage->SetSpacing(imageSpacing); - if (myImage->GetSpacing() != myAdaptor->GetSpacing()) - { - std::cout << "image spacing != adaptor spacing: " << myImage->GetSpacing() << " != " << myAdaptor->GetSpacing() - << std::endl; - return EXIT_FAILURE; - } - - myImageType::DirectionType imageDirection; - imageDirection.SetIdentity(); - imageDirection[1][1] = 10.0; - - myImage->SetDirection(imageDirection); - if (myImage->GetDirection() != myAdaptor->GetDirection()) - { - std::cout << "image direction != adaptor direction: " << myImage->GetDirection() - << " != " << myAdaptor->GetDirection() << std::endl; - return EXIT_FAILURE; - } - - // Now test the set methods of the adaptor - forigin[0] = 20.0; - myAdaptor->SetOrigin(forigin); - if (myImage->GetOrigin() != myAdaptor->GetOrigin()) - { - std::cout << "image origin != adaptor origin: " << myImage->GetOrigin() << " != " << myAdaptor->GetOrigin() - << std::endl; - return EXIT_FAILURE; - } - - dorigin[0] = 20.0; - myAdaptor->SetOrigin(dorigin); - if (myImage->GetOrigin() != myAdaptor->GetOrigin()) - { - std::cout << "image origin != adaptor origin: " << myImage->GetOrigin() << " != " << myAdaptor->GetOrigin() - << std::endl; - return EXIT_FAILURE; - } - - imageOrigin.Fill(100.0); - - myAdaptor->SetOrigin(imageOrigin); - if (myImage->GetOrigin() != myAdaptor->GetOrigin()) - { - std::cout << "image origin != adaptor origin: " << myImage->GetOrigin() << " != " << myAdaptor->GetOrigin() - << std::endl; - return EXIT_FAILURE; - } - - fspacing[0] = 20.0; - myAdaptor->SetSpacing(fspacing); - if (myImage->GetSpacing() != myAdaptor->GetSpacing()) - { - std::cout << "image spacing != adaptor spacing: " << myImage->GetSpacing() << " != " << myAdaptor->GetSpacing() - << std::endl; - return EXIT_FAILURE; - } - - dspacing[0] = 20.0; - myAdaptor->SetSpacing(dspacing); - if (myImage->GetSpacing() != myAdaptor->GetSpacing()) - { - std::cout << "image spacing != adaptor spacing: " << myImage->GetSpacing() << " != " << myAdaptor->GetSpacing() - << std::endl; - return EXIT_FAILURE; - } - - imageSpacing.Fill(100.0); - - myAdaptor->SetSpacing(imageSpacing); - if (myImage->GetSpacing() != myAdaptor->GetSpacing()) - { - std::cout << "image spacing != adaptor spacing: " << myImage->GetSpacing() << " != " << myAdaptor->GetSpacing() - << std::endl; - return EXIT_FAILURE; - } - - imageDirection[1][1] = 100.0; - - myAdaptor->SetDirection(imageDirection); - if (myImage->GetDirection() != myAdaptor->GetDirection()) - { - std::cout << "image direction != adaptor direction: " << myImage->GetDirection() - << " != " << myAdaptor->GetDirection() << std::endl; - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest1.cxx b/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest1.cxx deleted file mode 100644 index 0d6649cbdfb..00000000000 --- a/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest1.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkImageRegionIteratorWithIndex.h" -#include "itkTimeProbesCollectorBase.h" - -int -itkOrientedImageProfileTest1(int, char *[]) -{ - - constexpr unsigned int Dimension = 3; - using PixelType = unsigned char; - - using ImageType = itk::Image; - - using IndexType = ImageType::IndexType; - using SizeType = ImageType::SizeType; - using PointType = ImageType::PointType; - using RegionType = ImageType::RegionType; - using SpacingType = ImageType::SpacingType; - - IndexType start; - SizeType size; - - start.Fill(0); - size.Fill(300); - - RegionType region; - - region.SetIndex(start); - region.SetSize(size); - - auto image = ImageType::New(); - - image->SetRegions(region); - image->Allocate(); - - SpacingType spacing; - - spacing.Fill(1.5); - - image->SetSpacing(spacing); - - PointType origin; - - origin.Fill(1.3); - - image->SetOrigin(origin); - - using IteratorType = itk::ImageRegionConstIteratorWithIndex; - - IteratorType itr(image, region); - - itr.GoToBegin(); - - itk::TimeProbesCollectorBase chronometer; - - chronometer.Start("Transform"); - - IndexType index; - PointType point; - - while (!itr.IsAtEnd()) - { - image->TransformIndexToPhysicalPoint(itr.GetIndex(), point); - index = image->TransformPhysicalPointToIndex(point); - ++itr; - } - - chronometer.Stop("Transform"); - - chronometer.Report(std::cout); - - return EXIT_SUCCESS; -} diff --git a/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest2.cxx b/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest2.cxx deleted file mode 100644 index 629e6f5bd02..00000000000 --- a/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest2.cxx +++ /dev/null @@ -1,94 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkImageRegionIteratorWithIndex.h" -#include "itkTimeProbesCollectorBase.h" - -int -itkOrientedImageProfileTest2(int, char *[]) -{ - - constexpr unsigned int Dimension = 3; - using PixelType = unsigned char; - - // - // Yes, on purpose we are using here the itk::Image, so we can compare it - // against the itk::Image used in itkOrientedImageProfileTest1. - // - using ImageType = itk::Image; - - using IndexType = ImageType::IndexType; - using SizeType = ImageType::SizeType; - using PointType = ImageType::PointType; - using RegionType = ImageType::RegionType; - using SpacingType = ImageType::SpacingType; - - IndexType start; - SizeType size; - - start.Fill(0); - size.Fill(300); - - RegionType region; - - region.SetIndex(start); - region.SetSize(size); - - auto image = ImageType::New(); - - image->SetRegions(region); - image->Allocate(); - - SpacingType spacing; - - spacing.Fill(1.5); - - image->SetSpacing(spacing); - - PointType origin; - - origin.Fill(1.3); - - image->SetOrigin(origin); - - using IteratorType = itk::ImageRegionConstIteratorWithIndex; - - IteratorType itr(image, region); - - itr.GoToBegin(); - - itk::TimeProbesCollectorBase chronometer; - - chronometer.Start("Transform"); - - IndexType index; - PointType point; - - while (!itr.IsAtEnd()) - { - image->TransformIndexToPhysicalPoint(itr.GetIndex(), point); - index = image->TransformPhysicalPointToIndex(point); - ++itr; - } - - chronometer.Stop("Transform"); - - chronometer.Report(std::cout); - - return EXIT_SUCCESS; -} diff --git a/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest3.cxx b/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest3.cxx deleted file mode 100644 index 9ebb4c4a781..00000000000 --- a/Modules/Filtering/ImageGrid/test/itkOrientedImageProfileTest3.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkVectorImage.h" -#include "itkImageRegionIteratorWithIndex.h" -#include "itkTimeProbesCollectorBase.h" - -int -itkOrientedImageProfileTest3(int, char *[]) -{ - - constexpr unsigned int Dimension = 3; - using PixelType = unsigned char; - - // - // Yes, on purpose we are using here the itk::VectorImage, so we can compare it - // against the itk::Image used in itkOrientedImageProfileTest1. - // - using ImageType = itk::VectorImage; - - using IndexType = ImageType::IndexType; - using SizeType = ImageType::SizeType; - using PointType = ImageType::PointType; - using RegionType = ImageType::RegionType; - using SpacingType = ImageType::SpacingType; - - IndexType start; - SizeType size; - - start.Fill(0); - size.Fill(300); - - RegionType region; - - region.SetIndex(start); - region.SetSize(size); - - auto image = ImageType::New(); - - image->SetVectorLength(2); - image->SetRegions(region); - image->Allocate(); - - SpacingType spacing; - - spacing.Fill(1.5); - - image->SetSpacing(spacing); - - PointType origin; - - origin.Fill(1.3); - - image->SetOrigin(origin); - - using IteratorType = itk::ImageRegionConstIteratorWithIndex; - - IteratorType itr(image, region); - - itr.GoToBegin(); - - itk::TimeProbesCollectorBase chronometer; - - chronometer.Start("Transform"); - - IndexType index; - PointType point; - - while (!itr.IsAtEnd()) - { - image->TransformIndexToPhysicalPoint(itr.GetIndex(), point); - index = image->TransformPhysicalPointToIndex(point); - ++itr; - } - - chronometer.Stop("Transform"); - - chronometer.Report(std::cout); - - return EXIT_SUCCESS; -}