From ddd6563f034cac2f8f2d257a3a335c3ee2c146b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Fri, 24 Dec 2021 14:20:19 -0500 Subject: [PATCH] ENH: Increase coverage for miscellaneous classes Increase coverage for miscellaneous classes: - Exercise the basic object methods using the `ITK_EXERCISE_BASIC_OBJECT_METHODS` macro. - Test the Set/Get methods using the `ITK_TEST_SET_GET_VALUE` macro. - Test the boolean ivars using the `ITK_TEST_SET_GET_BOOLEAN` macro, and rely on it to set the boolean ivar values. - Make the calls to the Get methods be quantitative where they were just being called without being compared to the expected value. - Test exceptions using the `ITK_TRY_EXPECT_EXCEPTION` macro. - Convert existing hard-coded parameters to test input parameters and add parameters to the tests where appropriate so that different valued-tests can be added. - Remove explicit calls to the `Print` method and rely on the basic method exercising macro call. - Remove explicit calls to the `GetNameOfClass` and rely on the basic method exercising macro call. --- .../test/itkVectorImageToImageAdaptorTest.cxx | 4 + Modules/Core/Mesh/test/CMakeLists.txt | 2 +- .../itkExtractMeshConnectedRegionsTest.cxx | 16 +++ .../itkInteriorExteriorMeshFilterTest.cxx | 8 +- ...ametricSpaceToImageSpaceMeshFilterTest.cxx | 3 + .../itkSimplexMeshAdaptTopologyFilterTest.cxx | 22 +++- .../Core/Mesh/test/itkWarpMeshFilterTest.cxx | 4 + .../test/itkNewMetaObjectTypeTest.cxx | 10 ++ .../test/itkTubeSpatialObjectTest.cxx | 13 +- .../itkBSplineDeformableTransformTest.cxx | 26 ++-- .../itkRigid3DPerspectiveTransformTest.cxx | 40 +++++- ...torAnisotropicDiffusionImageFilterTest.cxx | 6 + .../itkMRIBiasFieldCorrectionFilterTest.cxx | 36 +++--- .../Filtering/Colormap/test/CMakeLists.txt | 26 ++-- .../itkScalarToRGBColormapImageFilterTest.cxx | 10 +- ...astSquaresDeconvolutionImageFilterTest.cxx | 7 ++ .../DisplacementField/test/CMakeLists.txt | 6 +- ...entialDisplacementFieldImageFilterTest.cxx | 30 +++-- ...InvertDisplacementFieldImageFilterTest.cxx | 26 ++-- ...nverseDisplacementFieldImageFilterTest.cxx | 16 ++- ...itkLandmarkDisplacementFieldSourceTest.cxx | 14 +++ ...elocityFieldIntegrationImageFilterTest.cxx | 82 ++++++++++--- .../Filtering/DistanceMap/test/CMakeLists.txt | 2 +- .../itkContourMeanDistanceImageFilterTest.cxx | 7 +- .../itkHausdorffDistanceImageFilterTest.cxx | 13 +- ...tkComplexToComplex1DFFTImageFilterTest.cxx | 11 +- .../itkComplexToComplexFFTImageFilterTest.cxx | 4 + ...kVnlComplexToComplexFFTImageFilterTest.cxx | 5 + .../FastMarching/test/CMakeLists.txt | 2 +- .../FastMarching/test/itkFastMarchingTest.cxx | 80 +++++++++--- .../test/itkFastMarchingTest2.cxx | 14 --- ...AbsoluteValueDifferenceImageFilterTest.cxx | 7 +- .../test/itkJoinImageFilterTest.cxx | 5 + ...etectionImageFilterTestBaseline.png.sha512 | 1 + .../ImageFeature/test/CMakeLists.txt | 10 +- .../itkHessianRecursiveGaussianFilterTest.cxx | 21 ++-- ...itkMaskFeaturePointSelectionFilterTest.cxx | 29 +++-- ...caleHessianBasedMeasureImageFilterTest.cxx | 23 ++-- .../itkSobelEdgeDetectionImageFilterTest.cxx | 65 +++++----- .../ImageGradient/test/CMakeLists.txt | 2 +- ...ntMagnitudeRecursiveGaussianFilterTest.cxx | 20 +-- .../Filtering/ImageGrid/test/CMakeLists.txt | 2 +- .../test/itkMirrorPadImageFilterTest.cxx | 4 + .../test/itkOrientImageFilterTest.cxx | 13 +- .../test/itkWarpVectorImageFilterTest.cxx | 27 +++-- .../itkZeroFluxNeumannPadImageFilterTest.cxx | 5 + .../itkVectorMagnitudeImageFilterTest.cxx | 4 + .../ImageStatistics/test/CMakeLists.txt | 10 +- .../itkGetAverageSliceImageFilterTest.cxx | 12 +- .../itkLabelStatisticsImageFilterTest.cxx | 18 ++- .../test/itkMinimumMaximumImageFilterTest.cxx | 13 +- .../test/itkStatisticsImageFilterTest.cxx | 4 +- .../Filtering/LabelMap/test/CMakeLists.txt | 4 +- ...econstructionByDilationImageFilterTest.cxx | 9 +- ...ReconstructionByErosionImageFilterTest.cxx | 11 +- .../test/itkShapeLabelMapFilterGTest.cxx | 28 +++++ .../test/CMakeLists.txt | 10 +- .../itkDoubleThresholdImageFilterTest.cxx | 13 +- ...caleGeodesicErodeDilateImageFilterTest.cxx | 26 +++- ...aleMorphologicalClosingImageFilterTest.cxx | 7 +- ...aleMorphologicalOpeningImageFilterTest.cxx | 7 +- ...MaximumCurvatureQuadEdgeMeshFilterTest.cxx | 5 + ...MinimumCurvatureQuadEdgeMeshFilterTest.cxx | 5 + .../test/itkNormalQuadEdgeMeshFilterTest.cxx | 9 +- ...termodesMaskedThresholdImageFilterTest.cxx | 3 +- .../itkIntermodesThresholdImageFilterTest.cxx | 3 +- .../test/itkMeshFileReaderWriterTest.cxx | 11 +- .../test/itkMeshFileWriteReadTensorTest.cxx | 10 +- .../test/itkReadWriteSpatialObjectTest.cxx | 20 ++- .../Numerics/Optimizers/test/CMakeLists.txt | 2 +- ...zationBiasedParticleSwarmOptimizerTest.cxx | 114 +++++++++++++++--- .../test/itkBlockMatchingImageFilterTest.cxx | 6 + ...tToSpatialObjectDemonsRegistrationTest.cxx | 9 +- ...HavrdaCharvatTsallisPointSetMetricTest.cxx | 31 ++++- ...feomorphicDemonsRegistrationFilterTest.cxx | 16 +-- ...esolutionPDEDeformableRegistrationTest.cxx | 32 ++--- .../itkBayesianClassifierImageFilterTest.cxx | 1 + ...calarConnectedComponentImageFilterTest.cxx | 6 +- .../DeformableMesh/test/CMakeLists.txt | 2 +- ...bleSimplexMesh3DBalloonForceFilterTest.cxx | 21 +++- .../test/itkBinaryMedianImageFilterTest.cxx | 9 ++ .../LevelSets/test/CMakeLists.txt | 4 +- ...naryMaskToNarrowBandPointSetFilterTest.cxx | 18 ++- .../itkCollidingFrontsImageFilterTest.cxx | 27 ++++- ...oldSegmentationLevelSetImageFilterTest.cxx | 6 + ...kShapeDetectionLevelSetImageFilterTest.cxx | 5 + ...oldSegmentationLevelSetImageFilterTest.cxx | 4 + .../itkLevelSetDomainMapImageFilterTest.cxx | 5 + .../Segmentation/Voronoi/test/CMakeLists.txt | 2 +- .../itkVoronoiSegmentationImageFilterTest.cxx | 48 +++++--- .../test/itkDecimateFramesVideoFilterTest.cxx | 3 + .../test/itkFrameAverageVideoFilterTest.cxx | 3 + .../itkFrameDifferenceVideoFilterTest.cxx | 3 + 93 files changed, 1058 insertions(+), 340 deletions(-) create mode 100644 Modules/Filtering/ImageFeature/test/Baseline/itkSobelEdgeDetectionImageFilterTestBaseline.png.sha512 diff --git a/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx b/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx index 04c2d39b871..3a52d181f5b 100644 --- a/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx +++ b/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx @@ -62,6 +62,10 @@ itkVectorImageToImageAdaptorTest(int, char *[]) // run the adaptor auto vectorImageToImageAdaptor = VectorImageToImageAdaptorType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(vectorImageToImageAdaptor, VectorImageToImageAdaptor, ImageAdaptor); + + vectorImageToImageAdaptor->SetExtractComponentIndex(componentToExtract); vectorImageToImageAdaptor->SetImage(vectorImage); diff --git a/Modules/Core/Mesh/test/CMakeLists.txt b/Modules/Core/Mesh/test/CMakeLists.txt index 51fd3c84a96..9bb30c5052b 100644 --- a/Modules/Core/Mesh/test/CMakeLists.txt +++ b/Modules/Core/Mesh/test/CMakeLists.txt @@ -58,7 +58,7 @@ itk_add_test(NAME itkRegularSphereMeshSourceTest itk_add_test(NAME itkRegularSphereMeshSourceTest2 COMMAND ITKMeshTestDriver itkRegularSphereMeshSourceTest2) itk_add_test(NAME itkSimplexMeshAdaptTopologyFilterTest - COMMAND ITKMeshTestDriver itkSimplexMeshAdaptTopologyFilterTest) + COMMAND ITKMeshTestDriver itkSimplexMeshAdaptTopologyFilterTest 0.5 0) itk_add_test(NAME itkSimplexMeshToTriangleMeshFilterTest COMMAND ITKMeshTestDriver itkSimplexMeshToTriangleMeshFilterTest) itk_add_test(NAME itkSimplexMeshVolumeCalculatorTest diff --git a/Modules/Core/Mesh/test/itkExtractMeshConnectedRegionsTest.cxx b/Modules/Core/Mesh/test/itkExtractMeshConnectedRegionsTest.cxx index 8be2f181d7c..c1500d8436a 100644 --- a/Modules/Core/Mesh/test/itkExtractMeshConnectedRegionsTest.cxx +++ b/Modules/Core/Mesh/test/itkExtractMeshConnectedRegionsTest.cxx @@ -18,6 +18,7 @@ #include "itkConnectedRegionsMeshFilter.h" #include "itkSphereMeshSource.h" +#include "itkTestingMacros.h" #include @@ -47,6 +48,9 @@ itkExtractMeshConnectedRegionsTest(int, char *[]) PointType p = pInit; auto connect = ConnectFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(connect, ConnectedRegionsMeshFilter, MeshToMeshFilter); + + connect->SetInput(inMesh); connect->SetClosestPoint(p); connect->AddSeed(0); @@ -58,21 +62,33 @@ itkExtractMeshConnectedRegionsTest(int, char *[]) // Test with each of the extraction modes connect->SetExtractionModeToAllRegions(); + auto extractionMode = 4; + ITK_TEST_SET_GET_VALUE(extractionMode, connect->GetExtractionMode()); connect->Update(); + extractionMode = 1; connect->SetExtractionModeToCellSeededRegions(); + ITK_TEST_SET_GET_VALUE(extractionMode, connect->GetExtractionMode()); connect->Update(); + extractionMode = 5; connect->SetExtractionModeToClosestPointRegion(); + ITK_TEST_SET_GET_VALUE(extractionMode, connect->GetExtractionMode()); connect->Update(); + extractionMode = 3; connect->SetExtractionModeToLargestRegion(); + ITK_TEST_SET_GET_VALUE(extractionMode, connect->GetExtractionMode()); connect->Update(); + extractionMode = 0; connect->SetExtractionModeToPointSeededRegions(); + ITK_TEST_SET_GET_VALUE(extractionMode, connect->GetExtractionMode()); connect->Update(); + extractionMode = 2; connect->SetExtractionModeToSpecifiedRegions(); + ITK_TEST_SET_GET_VALUE(extractionMode, connect->GetExtractionMode()); connect->Update(); // Create a Sphere for running the filter on real input data. diff --git a/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx index 3a84fc7bbbe..401b2426760 100644 --- a/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx @@ -19,6 +19,7 @@ #include "itkInteriorExteriorMeshFilter.h" #include "itkMesh.h" #include "itkSphereSpatialFunction.h" +#include "itkTestingMacros.h" int itkInteriorExteriorMeshFilterTest(int, char *[]) @@ -81,6 +82,9 @@ itkInteriorExteriorMeshFilterTest(int, char *[]) // Create a Filter auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, InteriorExteriorMeshFilter, MeshToMeshFilter); + + // Create the Spatial Function auto spatialFunction = SpatialFunctionType::New(); @@ -94,9 +98,11 @@ itkInteriorExteriorMeshFilterTest(int, char *[]) spatialFunction->SetCenter(center); spatialFunction->SetRadius(radius); + filter->SetSpatialFunction(spatialFunction); + ITK_TEST_SET_GET_VALUE(spatialFunction, filter->GetSpatialFunction()); + // Connect the inputs filter->SetInput(inputMesh); - filter->SetSpatialFunction(spatialFunction); // Execute the filter filter->Update(); diff --git a/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx index 57eb4e9beb0..0666b61dd42 100644 --- a/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx @@ -152,6 +152,9 @@ InternalTest(int argc, char * argv[]) return EXIT_FAILURE; } + ITK_EXERCISE_BASIC_OBJECT_METHODS(parametricFilter, ParametricSpaceToImageSpaceMeshFilter, MeshToMeshFilter); + + // Set the input mesh for the parametric filter parametricFilter->SetInput(mesh); diff --git a/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx b/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx index f4b77464e3a..c00ab94feda 100644 --- a/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx @@ -19,10 +19,17 @@ #include "itkTriangleMeshToSimplexMeshFilter.h" #include "itkSimplexMeshAdaptTopologyFilter.h" #include "itkDefaultDynamicMeshTraits.h" +#include "itkTestingMacros.h" int -itkSimplexMeshAdaptTopologyFilterTest(int, char *[]) +itkSimplexMeshAdaptTopologyFilterTest(int argc, char * argv[]) { + if (argc != 3) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " threshold selectionMethod" << std::endl; + return EXIT_FAILURE; + } // Declare the type of the input and output mesh using TriangleMeshTraits = itk::DefaultDynamicMeshTraits; @@ -62,9 +69,20 @@ itkSimplexMeshAdaptTopologyFilterTest(int, char *[]) using FilterType = itk::SimplexMeshAdaptTopologyFilter; auto filter = FilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, SimplexMeshAdaptTopologyFilter, MeshToMeshFilter); + + + auto threshold = std::stod(argv[1]); + filter->SetThreshold(threshold); + ITK_TEST_SET_GET_VALUE(threshold, filter->GetThreshold()); + + auto selectionMethod = std::stoi(argv[2]); + filter->SetSelectionMethod(selectionMethod); + ITK_TEST_SET_GET_VALUE(selectionMethod, filter->GetSelectionMethod()); + filter->SetInput(simplexMesh); filter->Update(); - filter->Print(std::cout); std::cout << "[TEST DONE]" << std::endl; diff --git a/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx index 9c45dbedf71..fb5541b5c00 100644 --- a/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx @@ -19,6 +19,7 @@ #include "itkWarpMeshFilter.h" #include "itkRegularSphereMeshSource.h" #include "itkImage.h" +#include "itkTestingMacros.h" int itkWarpMeshFilterTest(int, char *[]) @@ -102,6 +103,9 @@ itkWarpMeshFilterTest(int, char *[]) auto warpFilter = WarpFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(warpFilter, WarpMeshFilter, MeshToMeshFilter); + + warpFilter->SetInput(sphereMeshSource->GetOutput()); warpFilter->SetDisplacementField(deformationField); diff --git a/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx b/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx index 8628ae6e7ac..20bdc6adf44 100644 --- a/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx @@ -244,6 +244,16 @@ itkNewMetaObjectTypeTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(converter, MetaSceneConverter, Object); + auto binaryPoints = false; + ITK_TEST_SET_GET_BOOLEAN(converter, BinaryPoints, binaryPoints); + + unsigned int transformPrecision = 6; + converter->SetTransformPrecision(transformPrecision); + ITK_TEST_SET_GET_VALUE(transformPrecision, converter->GetTransformPrecision()); + + auto writeImagesInSeparateFile = false; + ITK_TEST_SET_GET_BOOLEAN(converter, WriteImagesInSeparateFile, writeImagesInSeparateFile); + converter->RegisterMetaConverter("Dummy", "DummySpatialObject", dummyConverter); MetaScene * metaScene = converter->CreateMetaScene(group); diff --git a/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx index efcb09408e0..d0b6ae7f5cf 100644 --- a/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx @@ -59,6 +59,9 @@ itkTubeSpatialObjectTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(tube1, TubeSpatialObject, PointBasedSpatialObject); + auto root = false; + ITK_TEST_SET_GET_BOOLEAN(tube1, Root, root); + tube1->GetProperty().SetName("Tube 1"); tube1->SetId(1); @@ -458,10 +461,11 @@ itkTubeSpatialObjectTest(int, char *[]) std::cout << "[PASSED]" << std::endl; - // Testing IsInside() with m_EndType set to rounded end-type; - std::cout << "IsInside() with m_RoundedEnd=True: "; + // Testing IsInside() with different end types + auto endRounded = false; + ITK_TEST_SET_GET_BOOLEAN(tube1, EndRounded, endRounded); + p1.Fill(19.5); - tube1->SetEndRounded(false); if (tube1->IsInsideInWorldSpace(p1)) { @@ -469,7 +473,8 @@ itkTubeSpatialObjectTest(int, char *[]) return EXIT_FAILURE; } - tube1->SetEndRounded(true); + endRounded = true; + ITK_TEST_SET_GET_BOOLEAN(tube1, EndRounded, endRounded); if (!tube1->IsInsideInWorldSpace(p1)) { diff --git a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx index ee93aeb6049..f6615808224 100644 --- a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx +++ b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx @@ -31,6 +31,7 @@ #include "itkVersorRigid3DTransform.h" #include "itkTextOutput.h" +#include "itkTestingMacros.h" /** * This module test the functionality of the BSplineDeformableTransform class. @@ -79,10 +80,23 @@ itkBSplineDeformableTransformTest1() */ auto transform = TransformType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(transform, BSplineDeformableTransform, BSplineBaseTransform); + transform->SetGridSpacing(spacing); + ITK_TEST_SET_GET_VALUE(spacing, transform->GetGridSpacing()); + transform->SetGridOrigin(origin); + ITK_TEST_SET_GET_VALUE(origin, transform->GetGridOrigin()); + transform->SetGridRegion(region); - transform->Print(std::cout); + ITK_TEST_SET_GET_VALUE(region, transform->GetGridRegion()); + + using DirectionType = TransformType::DirectionType; + DirectionType direction = transform->GetCoefficientImages()[0]->GetDirection(); + transform->SetGridDirection(direction); + ITK_TEST_SET_GET_VALUE(direction, transform->GetGridDirection()); + + std::cout << transform->GetValidRegion() << std::endl; /** * Allocate memory for the parameters @@ -138,7 +152,7 @@ itkBSplineDeformableTransformTest1() // optional: set bulk transform parameters transform->SetBulkTransform(bulkTransform); - std::cout << "BulkTransform: " << transform->GetBulkTransform() << std::endl; + ITK_TEST_SET_GET_VALUE(bulkTransform, transform->GetBulkTransform()); /** * Transform some points @@ -382,14 +396,6 @@ itkBSplineDeformableTransformTest1() } } - /** - * Exercise other methods - */ - std::cout << transform->GetGridRegion() << std::endl; - std::cout << transform->GetGridSpacing() << std::endl; - std::cout << transform->GetGridOrigin() << std::endl; - std::cout << transform->GetValidRegion() << std::endl; - using EvenOrderTransformType = itk::BSplineDeformableTransform; auto evenOrderTransform = EvenOrderTransformType::New(); if (evenOrderTransform.IsNull()) diff --git a/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx b/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx index 9b0b87a408c..0fddc11b624 100644 --- a/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx +++ b/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx @@ -19,7 +19,7 @@ #include #include "itkRigid3DPerspectiveTransform.h" - +#include "itkTestingMacros.h" int itkRigid3DPerspectiveTransformTest(int, char *[]) @@ -35,6 +35,44 @@ itkRigid3DPerspectiveTransformTest(int, char *[]) bool Ok = true; + // Test exceptions + { + auto transform = TransformType::New(); + + typename TransformType::InputVectorType vector{ { 1.0, 4.0, 9.0 } }; + ITK_TRY_EXPECT_EXCEPTION(transform->TransformVector(vector)); + + typename TransformType::InputVnlVectorType vnlVector; + vnlVector.fill(1.0); + ITK_TRY_EXPECT_EXCEPTION(transform->TransformVector(vnlVector)); + + typename TransformType::InputCovariantVectorType covVector; + covVector.Fill(1.0); + ITK_TRY_EXPECT_EXCEPTION(transform->TransformCovariantVector(covVector)); + + typename TransformType::InputPointType point{ { 1.0, 1.0, 1.0 } }; + typename TransformType::JacobianPositionType jacobianPosition; + ITK_TRY_EXPECT_EXCEPTION(transform->ComputeJacobianWithRespectToPosition(point, jacobianPosition)); + } + + // Exercise basic object methods and test Set/Get macros + { + auto transform = TransformType::New(); + + EXERCISE_BASIC_OBJECT_METHODS(transform, Rigid3DPerspectiveTransform, Transform); + + + typename TransformType::OffsetType fixedOffset; + fixedOffset.Fill(0); + + transform->SetFixedOffset(fixedOffset); + ITK_TEST_SET_GET_VALUE(fixedOffset, transform->GetFixedOffset()); + + typename TransformType::InputPointType centerOfRotation; + centerOfRotation.Fill(0); + transform->SetCenterOfRotation(centerOfRotation); + ITK_TEST_SET_GET_VALUE(centerOfRotation, transform->GetCenterOfRotation()); + } /* Create a 3D identity transformation and show its parameters */ { diff --git a/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx b/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx index 7a39fd1b271..88a9cd31904 100644 --- a/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx +++ b/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx @@ -20,6 +20,7 @@ #include "itkVectorGradientAnisotropicDiffusionImageFilter.h" #include "itkVectorCurvatureAnisotropicDiffusionImageFilter.h" #include "itkNullImageToImageFilterDriver.hxx" +#include "itkTestingMacros.h" inline std::ostream & operator<<(std::ostream & o, const itk::Vector & v) @@ -38,6 +39,11 @@ itkVectorAnisotropicDiffusionImageFilterTest(int itkNotUsed(argc), char * itkNot // Set up Gradient diffusion filter itk::VectorGradientAnisotropicDiffusionImageFilter::Pointer filter = itk::VectorGradientAnisotropicDiffusionImageFilter::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + filter, VectorGradientAnisotropicDiffusionImageFilter, AnisotropicDiffusionImageFilter); + + filter->SetNumberOfIterations(1); filter->SetConductanceParameter(3.0f); filter->SetTimeStep(0.125f); diff --git a/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx b/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx index bbde8aa4917..49dd1c8ad07 100644 --- a/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx +++ b/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx @@ -201,10 +201,6 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) double optimizerGrowthFactor = 1.01; bool usingInterSliceIntensityCorrection = true; - filter->SetBiasFieldMultiplicative(isBiasFieldMultiplicative); - filter->SetUsingSlabIdentification(usingSlabIdentification); - filter->SetUsingBiasFieldCorrection(usingBiasFieldCorrection); - filter->SetGeneratingOutput(generatingOutput); filter->SetSlabNumberOfSamples(slabNumberOfSamples); filter->SetSlabBackgroundMinimumThreshold(slabBackgroundMinimumThreshold); filter->SetSlabTolerance(slabTolerance); @@ -213,12 +209,11 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) filter->SetInterSliceCorrectionMaximumIteration(interSliceCorrectionMaximumIteration); filter->SetOptimizerInitialRadius(optimizerInitialRadius); filter->SetOptimizerGrowthFactor(optimizerGrowthFactor); - filter->SetUsingInterSliceIntensityCorrection(usingInterSliceIntensityCorrection); - ITK_TEST_SET_GET_VALUE(isBiasFieldMultiplicative, filter->GetBiasFieldMultiplicative()); - ITK_TEST_SET_GET_VALUE(usingSlabIdentification, filter->GetUsingSlabIdentification()); - ITK_TEST_SET_GET_VALUE(usingBiasFieldCorrection, filter->GetUsingBiasFieldCorrection()); - ITK_TEST_SET_GET_VALUE(generatingOutput, filter->GetGeneratingOutput()); + ITK_TEST_SET_GET_BOOLEAN(filter, BiasFieldMultiplicative, isBiasFieldMultiplicative); + ITK_TEST_SET_GET_BOOLEAN(filter, UsingSlabIdentification, usingSlabIdentification); + ITK_TEST_SET_GET_BOOLEAN(filter, UsingBiasFieldCorrection, usingBiasFieldCorrection); + ITK_TEST_SET_GET_BOOLEAN(filter, GeneratingOutput, generatingOutput); ITK_TEST_SET_GET_VALUE(slabNumberOfSamples, filter->GetSlabNumberOfSamples()); ITK_TEST_SET_GET_VALUE(slabBackgroundMinimumThreshold, filter->GetSlabBackgroundMinimumThreshold()); ITK_TEST_SET_GET_VALUE(slabTolerance, filter->GetSlabTolerance()); @@ -227,15 +222,14 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) ITK_TEST_SET_GET_VALUE(interSliceCorrectionMaximumIteration, filter->GetInterSliceCorrectionMaximumIteration()); ITK_TEST_SET_GET_VALUE(optimizerInitialRadius, filter->GetOptimizerInitialRadius()); ITK_TEST_SET_GET_VALUE(optimizerGrowthFactor, filter->GetOptimizerGrowthFactor()); - ITK_TEST_SET_GET_VALUE(usingInterSliceIntensityCorrection, filter->GetUsingInterSliceIntensityCorrection()); + ITK_TEST_SET_GET_BOOLEAN(filter, UsingInterSliceIntensityCorrection, usingInterSliceIntensityCorrection); - filter->SetBiasFieldMultiplicative(true); // correct with multiplicative bias - filter->SetBiasFieldDegree(biasDegree); // default value = 3 + filter->SetBiasFieldDegree(biasDegree); // default value = 3 filter->SetTissueClassStatistics(classMeans, classSigmas); // ITK_TEST_SET_GET_VALUE( classMeans, classSigmas, filter->GetTissueClassStatistics() ); filter->SetSlicingDirection(slicingDirection); - // ITK_TEST_SET_GET_VALUE( slicingDirection, filter->GetSlicingDirection() ); + ITK_TEST_SET_GET_VALUE(slicingDirection, filter->GetSlicingDirection()); filter->SetInitialBiasFieldCoefficients(initCoefficients); // ITK_TEST_SET_GET_VALUE( initCoefficients, filter->GetInitialBiasFieldCoefficients() ); @@ -286,8 +280,12 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) std::cout << "Computing bias correction with mask" << std::endl; filter->SetInput(imageWithBias); + filter->SetInputMask(image); + ITK_TEST_SET_GET_VALUE(image, filter->GetInputMask()); + filter->SetOutputMask(image); + ITK_TEST_SET_GET_VALUE(image, filter->GetOutputMask()); volumeCorrectionMaximumIteration = 200; interSliceCorrectionMaximumIteration = 100; @@ -338,15 +336,13 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) interSliceCorrectionMaximumIteration = 100; optimizerInitialRadius = 0.02; - filter->SetUsingInterSliceIntensityCorrection(usingInterSliceIntensityCorrection); - filter->SetUsingSlabIdentification(usingSlabIdentification); filter->SetOptimizerInitialRadius(optimizerInitialRadius); filter->SetVolumeCorrectionMaximumIteration(volumeCorrectionMaximumIteration); filter->SetInterSliceCorrectionMaximumIteration(interSliceCorrectionMaximumIteration); filter->SetOptimizerInitialRadius(optimizerInitialRadius); - ITK_TEST_SET_GET_VALUE(usingInterSliceIntensityCorrection, filter->GetUsingInterSliceIntensityCorrection()); - ITK_TEST_SET_GET_VALUE(usingSlabIdentification, filter->GetUsingSlabIdentification()); + ITK_TEST_SET_GET_BOOLEAN(filter, UsingInterSliceIntensityCorrection, usingInterSliceIntensityCorrection); + ITK_TEST_SET_GET_BOOLEAN(filter, UsingSlabIdentification, usingSlabIdentification); ITK_TEST_SET_GET_VALUE(optimizerInitialRadius, filter->GetOptimizerInitialRadius()); ITK_TEST_SET_GET_VALUE(volumeCorrectionMaximumIteration, filter->GetVolumeCorrectionMaximumIteration()); ITK_TEST_SET_GET_VALUE(interSliceCorrectionMaximumIteration, filter->GetInterSliceCorrectionMaximumIteration()); @@ -402,8 +398,6 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) volumeCorrectionMaximumIteration = 200; interSliceCorrectionMaximumIteration = 100; - filter->SetUsingInterSliceIntensityCorrection(usingInterSliceIntensityCorrection); - filter->SetUsingSlabIdentification(usingSlabIdentification); filter->SetOptimizerInitialRadius(optimizerInitialRadius); filter->SetVolumeCorrectionMaximumIteration(volumeCorrectionMaximumIteration); filter->SetInterSliceCorrectionMaximumIteration(interSliceCorrectionMaximumIteration); @@ -413,8 +407,8 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) filter->SetNumberOfLevels(numberOfLevels); filter->SetSchedule(schedule); - ITK_TEST_SET_GET_VALUE(usingInterSliceIntensityCorrection, filter->GetUsingInterSliceIntensityCorrection()); - ITK_TEST_SET_GET_VALUE(usingSlabIdentification, filter->GetUsingSlabIdentification()); + ITK_TEST_SET_GET_BOOLEAN(filter, UsingInterSliceIntensityCorrection, usingInterSliceIntensityCorrection); + ITK_TEST_SET_GET_BOOLEAN(filter, UsingSlabIdentification, usingSlabIdentification); ITK_TEST_SET_GET_VALUE(numberOfLevels, filter->GetNumberOfLevels()); ITK_TEST_SET_GET_VALUE(optimizerInitialRadius, filter->GetOptimizerInitialRadius()); ITK_TEST_SET_GET_VALUE(schedule, filter->GetSchedule()); diff --git a/Modules/Filtering/Colormap/test/CMakeLists.txt b/Modules/Filtering/Colormap/test/CMakeLists.txt index f5322065649..8c708764cdd 100644 --- a/Modules/Filtering/Colormap/test/CMakeLists.txt +++ b/Modules/Filtering/Colormap/test/CMakeLists.txt @@ -16,76 +16,76 @@ itk_add_test(NAME RGBColormapTest_red --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_red.png DATA{Baseline/RGBColormapTest_red.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_red.png red) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_red.png red 1) itk_add_test(NAME RGBColormapTest_green COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_green.png DATA{Baseline/RGBColormapTest_green.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_green.png green) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_green.png green 1) itk_add_test(NAME RGBColormapTest_blue COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_blue.png DATA{Baseline/RGBColormapTest_blue.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_blue.png blue) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_blue.png blue 1) itk_add_test(NAME RGBColormapTest_hot COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_hot.png DATA{Baseline/RGBColormapTest_hot.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_hot.png hot) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_hot.png hot 1) itk_add_test(NAME RGBColormapTest_cool COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_cool.png DATA{Baseline/RGBColormapTest_cool.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_cool.png cool) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_cool.png cool 1) itk_add_test(NAME RGBColormapTest_spring COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_spring.png DATA{Baseline/RGBColormapTest_spring.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_spring.png spring) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_spring.png spring 1) itk_add_test(NAME RGBColormapTest_summer COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_summer.png DATA{Baseline/RGBColormapTest_summer.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_summer.png summer) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_summer.png summer 1) itk_add_test(NAME RGBColormapTest_autumn COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_autumn.png DATA{Baseline/RGBColormapTest_autumn.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_autumn.png autumn) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_autumn.png autumn 1) itk_add_test(NAME RGBColormapTest_winter COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_winter.png DATA{Baseline/RGBColormapTest_winter.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_winter.png winter) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_winter.png winter 1) itk_add_test(NAME RGBColormapTest_copper COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_copper.png DATA{Baseline/RGBColormapTest_copper.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_copper.png copper) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_copper.png copper 1) itk_add_test(NAME RGBColormapTest_hsv COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_hsv.png DATA{Baseline/RGBColormapTest_hsv.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_hsv.png hsv) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_hsv.png hsv 1) itk_add_test(NAME RGBColormapTest_jet COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_jet.png DATA{Baseline/RGBColormapTest_jet.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_jet.png jet) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_jet.png jet 1) itk_add_test(NAME RGBColormapTest_overunder COMMAND ITKColormapTestDriver --compare ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_overunder.png DATA{Baseline/RGBColormapTest_overunder.png} itkScalarToRGBColormapImageFilterTest - DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_overunder.png overunder) + DATA{Input/Colormap_Grey.png} ${ITK_TEST_OUTPUT_DIR}/RGBColormapTest_overunder.png overunder 1) diff --git a/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx b/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx index 3e773fc9521..50faf533c31 100644 --- a/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx +++ b/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx @@ -30,10 +30,10 @@ int itkScalarToRGBColormapImageFilterTest(int argc, char * argv[]) { - if (argc < 4) + if (argc < 5) { std::cout << "Usage: " << itkNameOfTestExecutableMacro(argv) - << " inputImage outputImage colormap [customColormapFile]" << std::endl; + << " inputImage outputImage colormap useInputImageExtremaForScaling [customColormapFile]" << std::endl; std::cout << " Possible colormaps: grey, red, green, blue, copper, jet, hsv, "; std::cout << "spring, summer, autumn, winter, hot, cool, custom" << std::endl; return EXIT_FAILURE; @@ -64,6 +64,10 @@ itkScalarToRGBColormapImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(rgbfilter, ScalarToRGBColormapImageFilter, ImageToImageFilter); + + auto useInputImageExtremaForScaling = static_cast(std::stoi(argv[4])); + ITK_TEST_SET_GET_BOOLEAN(rgbfilter, UseInputImageExtremaForScaling, useInputImageExtremaForScaling); + rgbfilter->SetInput(reader->GetOutput()); vfilter->SetInput(reader->GetOutput()); @@ -186,6 +190,8 @@ itkScalarToRGBColormapImageFilterTest(int argc, char * argv[]) vcolormap->SetBlueChannel(channel); rgbfilter->SetColormap(colormap); vfilter->SetColormap(vcolormap); + + ITK_TEST_SET_GET_VALUE(colormap, rgbfilter->GetColormap()); } using RGBHasher = itk::Testing::HashImageFilter; diff --git a/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx index 4a3ace0120e..4080bf5e9e2 100644 --- a/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx @@ -195,7 +195,14 @@ itkParametricBlindLeastSquaresDeconvolutionImageFilterTest(int argc, char * argv // Create an instance of the deconvolution filter using DeconvolutionFilterType = itk::ParametricBlindLeastSquaresDeconvolutionImageFilter; auto deconvolutionFilter = DeconvolutionFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + deconvolutionFilter, ParametricBlindLeastSquaresDeconvolutionImageFilter, IterativeDeconvolutionImageFilter); + + deconvolutionFilter->SetKernelSource(kernelSource); + ITK_TEST_SET_GET_VALUE(kernelSource, deconvolutionFilter->GetKernelSource()); + deconvolutionFilter->SetSizeGreatestPrimeFactor(5); // Change the sigma settings here to something different diff --git a/Modules/Filtering/DisplacementField/test/CMakeLists.txt b/Modules/Filtering/DisplacementField/test/CMakeLists.txt index 90e2df99a1f..03b76e6ccb3 100644 --- a/Modules/Filtering/DisplacementField/test/CMakeLists.txt +++ b/Modules/Filtering/DisplacementField/test/CMakeLists.txt @@ -29,7 +29,7 @@ itk_add_test(NAME itkDisplacementFieldJacobianDeterminantFilterTest COMMAND ITKDisplacementFieldTestDriver itkDisplacementFieldJacobianDeterminantFilterTest) itk_add_test(NAME itkIterativeInverseDisplacementFieldImageFilterTest COMMAND ITKDisplacementFieldTestDriver itkIterativeInverseDisplacementFieldImageFilterTest - ${ITK_TEST_OUTPUT_DIR}/itkIterativeInverseDisplacementFieldImageFilterTest.mha) + ${ITK_TEST_OUTPUT_DIR}/itkIterativeInverseDisplacementFieldImageFilterTest.mha 5 0) itk_add_test(NAME itkLandmarkDisplacementFieldSourceTest COMMAND ITKDisplacementFieldTestDriver itkLandmarkDisplacementFieldSourceTest ${ITK_TEST_OUTPUT_DIR}/itkLandmarkDisplacementFieldSourceTestLandmarks.txt ${ITK_TEST_OUTPUT_DIR}/itkLandmarkDisplacementFieldSourceTest.mha) @@ -53,11 +53,11 @@ itk_add_test(NAME itkBSplineExponentialDiffeomorphicTransformTest itk_add_test(NAME itkTimeVaryingVelocityFieldTransformTest COMMAND ITKDisplacementFieldTestDriver itkTimeVaryingVelocityFieldTransformTest ) itk_add_test(NAME itkTimeVaryingVelocityFieldIntegrationImageFilterTest - COMMAND ITKDisplacementFieldTestDriver itkTimeVaryingVelocityFieldIntegrationImageFilterTest ) + COMMAND ITKDisplacementFieldTestDriver itkTimeVaryingVelocityFieldIntegrationImageFilterTest 0.3 0.75 100 0.2 0.8 50 1.0 0.0 100) itk_add_test(NAME itkTimeVaryingBSplineVelocityFieldTransformTest COMMAND ITKDisplacementFieldTestDriver itkTimeVaryingBSplineVelocityFieldTransformTest ) itk_add_test(NAME itkInvertDisplacementFieldImageFilterTest - COMMAND ITKDisplacementFieldTestDriver itkInvertDisplacementFieldImageFilterTest 0) + COMMAND ITKDisplacementFieldTestDriver itkInvertDisplacementFieldImageFilterTest 50 0.1 0.001 0) itk_add_test(NAME itkDisplacementFieldToBSplineImageFilterTest COMMAND ITKDisplacementFieldTestDriver itkDisplacementFieldToBSplineImageFilterTest ) itk_add_test(NAME itkTransformToDisplacementFieldFilterTest01 diff --git a/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx index c9831952ca0..ba585aa96df 100644 --- a/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx @@ -17,7 +17,7 @@ *=========================================================================*/ #include "itkExponentialDisplacementFieldImageFilter.h" - +#include "itkTestingMacros.h" #include "vnl/vnl_random.h" @@ -91,11 +91,17 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) // Create one filter auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ExponentialDisplacementFieldImageFilter, ImageToImageFilter); // Connect the input images filter->SetInput(inputImage); - filter->SetMaximumNumberOfIterations(20); + auto automaticNumberOfIterations = true; + ITK_TEST_SET_GET_BOOLEAN(filter, AutomaticNumberOfIterations, automaticNumberOfIterations); + + unsigned int maximumNumberOfIterations = 20; + filter->SetMaximumNumberOfIterations(maximumNumberOfIterations); + ITK_TEST_SET_GET_VALUE(maximumNumberOfIterations, filter->GetMaximumNumberOfIterations()); // Execute the filter filter->Update(); @@ -129,7 +135,8 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) // Ask for the inverse deformation - filter->ComputeInverseOn(); + auto computeInverse = true; + ITK_TEST_SET_GET_BOOLEAN(filter, ComputeInverse, computeInverse); // Execute the filter filter->Update(); @@ -160,8 +167,10 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) // Try with 0 iterations - filter->ComputeInverseOff(); - filter->SetMaximumNumberOfIterations(0); + computeInverse = false; + filter->SetComputeInverse(computeInverse); + maximumNumberOfIterations = 0; + filter->SetMaximumNumberOfIterations(maximumNumberOfIterations); // Execute the filter filter->Update(); @@ -192,8 +201,9 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) // Try inverse with 0 iterations - filter->ComputeInverseOn(); - filter->SetMaximumNumberOfIterations(0); + computeInverse = true; + filter->SetComputeInverse(computeInverse); + filter->SetMaximumNumberOfIterations(maximumNumberOfIterations); // Execute the filter filter->Update(); @@ -234,8 +244,10 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) } filter->SetInput(inputImage); - filter->SetMaximumNumberOfIterations(20); - filter->ComputeInverseOff(); + maximumNumberOfIterations = 20; + filter->SetMaximumNumberOfIterations(maximumNumberOfIterations); + computeInverse = false; + filter->SetComputeInverse(computeInverse); // Random number generator vnl_random rng; diff --git a/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx index d31722192c7..b750d4b8954 100644 --- a/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx @@ -23,10 +23,11 @@ int itkInvertDisplacementFieldImageFilterTest(int argc, char * argv[]) { - if (argc != 2) + if (argc != 5) { std::cerr << "Missing parameters." << std::endl; - std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " enforceBoundaryCondition" << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) + << " numberOfIterations meanTolerance maxTolerance enforceBoundaryCondition" << std::endl; return EXIT_FAILURE; } @@ -87,28 +88,29 @@ itkInvertDisplacementFieldImageFilterTest(int argc, char * argv[]) } } - unsigned int numberOfIterations = 50; - float maxTolerance = 0.1; - float meanTolerance = 0.001; - using InverterType = itk::InvertDisplacementFieldImageFilter; auto inverter = InverterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(inverter, InvertDisplacementFieldImageFilter, ImageToImageFilter); - inverter->SetInput(field); + auto numberOfIterations = static_cast(std::stoi(argv[1])); inverter->SetMaximumNumberOfIterations(numberOfIterations); + ITK_TEST_SET_GET_VALUE(numberOfIterations, inverter->GetMaximumNumberOfIterations()); + + auto meanTolerance = static_cast(std::stod(argv[2])); inverter->SetMeanErrorToleranceThreshold(meanTolerance); - inverter->SetMaxErrorToleranceThreshold(maxTolerance); + ITK_TEST_SET_GET_VALUE(meanTolerance, inverter->GetMeanErrorToleranceThreshold()); - std::cout << "number of iterations: " << inverter->GetMaximumNumberOfIterations() << std::endl; - std::cout << "mean error tolerance: " << inverter->GetMeanErrorToleranceThreshold() << std::endl; - std::cout << "max error tolerance: " << inverter->GetMaxErrorToleranceThreshold() << std::endl; + auto maxTolerance = static_cast(std::stod(argv[3])); + inverter->SetMaxErrorToleranceThreshold(maxTolerance); + ITK_TEST_SET_GET_VALUE(maxTolerance, inverter->GetMaxErrorToleranceThreshold()); - auto enforceBoundaryCondition = static_cast(std::stoi(argv[1])); + auto enforceBoundaryCondition = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(inverter, EnforceBoundaryCondition, enforceBoundaryCondition); + inverter->SetInput(field); + try { inverter->Update(); diff --git a/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx index 4005b852f33..a89aaebd0fa 100644 --- a/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx @@ -26,11 +26,11 @@ int itkIterativeInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) { - if (argc < 2) + if (argc < 4) { std::cerr << "Missing Parameters " << std::endl; std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); - std::cerr << " outputImage" << std::endl; + std::cerr << " outputImage numberOfIterations stopValue" << std::endl; return EXIT_FAILURE; } @@ -45,8 +45,20 @@ itkIterativeInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, IterativeInverseDisplacementFieldImageFilter, ImageToImageFilter); + + itk::SimpleFilterWatcher watcher(filter); + auto numberOfIterations = static_cast(std::stoi(argv[2])); + filter->SetNumberOfIterations(numberOfIterations); + ITK_TEST_SET_GET_VALUE(numberOfIterations, filter->GetNumberOfIterations()); + + auto stopValue = std::stod(argv[3]); + filter->SetStopValue(stopValue); + ITK_TEST_SET_GET_VALUE(stopValue, filter->GetStopValue()); + + // Creating an input displacement field auto field = DisplacementFieldType::New(); diff --git a/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx b/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx index 90821d12a8a..65bbf70bf93 100644 --- a/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx @@ -19,6 +19,7 @@ #include "itkLandmarkDisplacementFieldSource.h" #include "itkImageFileWriter.h" #include "itkSimpleFilterWatcher.h" +#include "itkThinPlateSplineKernelTransform.h" #include #include "itkTestingMacros.h" @@ -47,6 +48,9 @@ itkLandmarkDisplacementFieldSourceTest(int argc, char * argv[]) auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, LandmarkDisplacementFieldSource, ImageSource); + + itk::SimpleFilterWatcher watcher(filter); DisplacementFieldType::SpacingType spacing; @@ -71,11 +75,21 @@ itkLandmarkDisplacementFieldSourceTest(int argc, char * argv[]) DisplacementFieldType::DirectionType direction; direction.SetIdentity(); + auto kernelTransform = itk::ThinPlateSplineKernelTransform::New(); + filter->SetKernelTransform(kernelTransform); + ITK_TEST_SET_GET_VALUE(kernelTransform, filter->GetKernelTransform()); filter->SetOutputSpacing(spacing); + ITK_TEST_SET_GET_VALUE(spacing, filter->GetOutputSpacing()); + filter->SetOutputOrigin(origin); + ITK_TEST_SET_GET_VALUE(origin, filter->GetOutputOrigin()); + filter->SetOutputRegion(region); + ITK_TEST_SET_GET_VALUE(region, filter->GetOutputRegion()); + filter->SetOutputDirection(direction); + ITK_TEST_SET_GET_VALUE(direction, filter->GetOutputDirection()); // Create source and target landmarks. // diff --git a/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx index 3c2a63839f7..74c62708c3d 100644 --- a/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx @@ -18,10 +18,26 @@ #include "itkTimeVaryingVelocityFieldIntegrationImageFilter.h" #include "itkImportImageFilter.h" +#include "itkTestingMacros.h" int -itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int, char *[]) +itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int argc, char * argv[]) { + if (argc != 10) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " homoConstLowerTimeBound" + << " homoConstUpperTimeBound" + << " homoConstNumberOfIntegrationSteps" + << " heterogVarConstLowerTimeBound" + << " heterogVarConstUpperTimeBound" + << " heterogVarNumberOfIntegrationSteps" + << " invLowerTimeBound" + << " invUpperTimeBound" + << " invNumberOfIntegrationSteps" << std::endl; + return EXIT_FAILURE; + } + /* First test with homogeneous and constant velocity field */ using VectorType = itk::Vector; @@ -52,23 +68,49 @@ itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int, char *[]) using IntegratorType = itk::TimeVaryingVelocityFieldIntegrationImageFilter; auto integrator = IntegratorType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(integrator, TimeVaryingVelocityFieldIntegrationImageFilter, ImageToImageFilter); + + + auto lowerTimeBound = static_cast(std::stod(argv[1])); + integrator->SetLowerTimeBound(lowerTimeBound); + ITK_TEST_SET_GET_VALUE(lowerTimeBound, integrator->GetLowerTimeBound()); + + auto upperTimeBound = static_cast(std::stod(argv[2])); + integrator->SetUpperTimeBound(upperTimeBound); + ITK_TEST_SET_GET_VALUE(upperTimeBound, integrator->GetUpperTimeBound()); + + auto numberOfIntegrationSteps = static_cast(std::stoi(argv[3])); + integrator->SetNumberOfIntegrationSteps(numberOfIntegrationSteps); + ITK_TEST_SET_GET_VALUE(numberOfIntegrationSteps, integrator->GetNumberOfIntegrationSteps()); + + auto timeBoundsAsRates = true; + ITK_TEST_SET_GET_BOOLEAN(integrator, TimeBoundsAsRates, timeBoundsAsRates); + integrator->SetInput(constantVelocityField); - integrator->SetLowerTimeBound(0.3); - integrator->SetUpperTimeBound(0.75); - integrator->SetNumberOfIntegrationSteps(100); - integrator->Update(); - integrator->Print(std::cout, 3); + integrator->Update(); DisplacementFieldType::IndexType index; index.Fill(0); VectorType displacement; auto inverseIntegrator = IntegratorType::New(); + + auto invLowerTimeBound = static_cast(std::stod(argv[7])); + inverseIntegrator->SetLowerTimeBound(invLowerTimeBound); + ITK_TEST_SET_GET_VALUE(invLowerTimeBound, inverseIntegrator->GetLowerTimeBound()); + + auto invUpperTimeBound = static_cast(std::stod(argv[8])); + inverseIntegrator->SetUpperTimeBound(invUpperTimeBound); + ITK_TEST_SET_GET_VALUE(invUpperTimeBound, inverseIntegrator->GetUpperTimeBound()); + + auto invNumberOfIntegrationSteps = static_cast(std::stoi(argv[9])); + inverseIntegrator->SetNumberOfIntegrationSteps(invNumberOfIntegrationSteps); + ITK_TEST_SET_GET_VALUE(invNumberOfIntegrationSteps, inverseIntegrator->GetNumberOfIntegrationSteps()); + inverseIntegrator->SetInput(constantVelocityField); - inverseIntegrator->SetLowerTimeBound(1.0); - inverseIntegrator->SetUpperTimeBound(0.0); - inverseIntegrator->SetNumberOfIntegrationSteps(100); + inverseIntegrator->Update(); // This integration should result in a constant image of value @@ -84,10 +126,6 @@ itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int, char *[]) return EXIT_FAILURE; } - inverseIntegrator->Print(std::cout, 3); - - std::cout << inverseIntegrator->GetNameOfClass() << std::endl; - // This integration should result in a constant image of value // 0.75 * 0.1 - 0.3 * 0.1 = 0.045 with ~epsilon deviation // due to numerical computations @@ -170,19 +208,23 @@ itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int, char *[]) TimeVaryingVelocityFieldType::Pointer timeVaryingVelocityField = importFilter->GetOutput(); + lowerTimeBound = static_cast(std::stod(argv[4])); + integrator->SetLowerTimeBound(lowerTimeBound); + + upperTimeBound = static_cast(std::stod(argv[5])); + integrator->SetUpperTimeBound(upperTimeBound); + integrator->SetInput(timeVaryingVelocityField); - integrator->SetLowerTimeBound(0.2); - integrator->SetUpperTimeBound(0.8); /* This time bounds are meant to be absolute * for the velocity field original time span [0, 1.5]. * Thus, we need to switch off the default rescaling * to the normalized time span [0, 1] */ integrator->TimeBoundsAsRatesOff(); - integrator->SetNumberOfIntegrationSteps(50); - integrator->Update(); + numberOfIntegrationSteps = static_cast(std::stod(argv[6])); + integrator->SetNumberOfIntegrationSteps(numberOfIntegrationSteps); - integrator->Print(std::cout, 3); + integrator->Update(); index[0] = (size[0] - 1) / 2; // Corresponding to x = 10. index[1] = (size[1] - 1) / 2; // Corresponding to y = 10. @@ -200,8 +242,8 @@ itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int, char *[]) } /* The same integrator is used backwards in time. */ - integrator->SetLowerTimeBound(1.0); - integrator->SetUpperTimeBound(0.0); + integrator->SetLowerTimeBound(invLowerTimeBound); + integrator->SetUpperTimeBound(invUpperTimeBound); integrator->Update(); inverseField = integrator->GetOutput(); diff --git a/Modules/Filtering/DistanceMap/test/CMakeLists.txt b/Modules/Filtering/DistanceMap/test/CMakeLists.txt index b7d0d10b9d2..3e218da9210 100644 --- a/Modules/Filtering/DistanceMap/test/CMakeLists.txt +++ b/Modules/Filtering/DistanceMap/test/CMakeLists.txt @@ -91,7 +91,7 @@ itk_add_test(NAME itkFastChamferDistanceImageFilterTest3 itk_add_test(NAME itkFastChamferDistanceImageFilterTest4 COMMAND ITKDistanceMapTestDriver itkFastChamferDistanceImageFilterTest 4) itk_add_test(NAME itkHausdorffDistanceImageFilterTest - COMMAND ITKDistanceMapTestDriver itkHausdorffDistanceImageFilterTest) + COMMAND ITKDistanceMapTestDriver itkHausdorffDistanceImageFilterTest 1) itk_add_test(NAME itkReflectiveImageRegionIteratorTest COMMAND ITKDistanceMapTestDriver itkReflectiveImageRegionIteratorTest) itk_add_test(NAME itkSignedMaurerDistanceMapImageFilterTest1 diff --git a/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx index 1e0c2e356c6..31c6a69c44c 100644 --- a/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx @@ -91,13 +91,16 @@ itkContourMeanDistanceImageFilterTest(int argc, char * argv[]) // compute the directed Mean distance h(image1,image2) { using FilterType = itk::ContourMeanDistanceImageFilter; - auto filter = FilterType::New(); + auto filter = FilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ContourMeanDistanceImageFilter, ImageToImageFilter); + + itk::SimpleFilterWatcher watcher(filter, "filter"); filter->SetInput1(image1); filter->SetInput2(image2); filter->Update(); - filter->Print(std::cout); // check results diff --git a/Modules/Filtering/DistanceMap/test/itkHausdorffDistanceImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkHausdorffDistanceImageFilterTest.cxx index ec8e6c1b42a..0d77ee2ce42 100644 --- a/Modules/Filtering/DistanceMap/test/itkHausdorffDistanceImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkHausdorffDistanceImageFilterTest.cxx @@ -21,8 +21,14 @@ #include "itkTestingMacros.h" int -itkHausdorffDistanceImageFilterTest(int, char *[]) +itkHausdorffDistanceImageFilterTest(int argc, char * argv[]) { + if (argc != 2) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " useImageSpacing" << std::endl; + return EXIT_FAILURE; + } constexpr unsigned int ImageDimension = 3; @@ -159,9 +165,12 @@ itkHausdorffDistanceImageFilterTest(int, char *[]) using FilterType = itk::HausdorffDistanceImageFilter; auto filter = FilterType::New(); + auto useImageSpacing = static_cast(std::stoi(argv[1])); + filter->SetUseImageSpacing(useImageSpacing); + ITK_TEST_SET_GET_VALUE(useImageSpacing, filter->GetUseImageSpacing()); + filter->SetInput1(image2); filter->SetInput2(image1); - filter->SetUseImageSpacing(true); filter->Update(); // Check results diff --git a/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx index 96f42de4ac2..56435c62569 100644 --- a/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx @@ -57,7 +57,11 @@ doTest(const char * inputRealFullImage, const char * inputImaginaryFullImage, co readerImag->SetFileName(inputImaginaryFullImage); joinFilter->SetInput1(readerReal->GetOutput()); joinFilter->SetInput2(readerImag->GetOutput()); - fft->SetTransformDirection(FFTType::INVERSE); + + auto transformDirection = FFTType::INVERSE; + fft->SetTransformDirection(transformDirection); + ITK_TEST_SET_GET_VALUE(transformDirection, fft->GetTransformDirection()); + fft->SetInput(joinFilter->GetOutput()); toReal->SetInput(fft->GetOutput()); writer->SetInput(toReal->GetOutput()); @@ -66,8 +70,6 @@ doTest(const char * inputRealFullImage, const char * inputImaginaryFullImage, co ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); - fft.Print(std::cout); - return EXIT_SUCCESS; } @@ -110,12 +112,15 @@ itkComplexToComplex1DFFTImageFilterTest(int argc, char * argv[]) #endif using FFTInverseType = itk::ComplexToComplex1DFFTImageFilter; auto inverse = FFTInverseType::New(); + if (inverse == nullptr) { std::cerr << "Failed to register a backend for ComplexToComplex1DFFTImageFilter" << std::endl; return EXIT_FAILURE; } + // ITK_EXERCISE_BASIC_OBJECT_METHODS(inverse, ComplexToComplex1DFFTImageFilter, ImageToImageFilter); + return doTest(argv[1], argv[2], argv[3]); } else if (backend == 1) diff --git a/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx index d16c5785096..457850bcfef 100644 --- a/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx @@ -88,6 +88,10 @@ transformImage(const char * inputImageFileName, const char * outputImageFileName using ComplexFilterType = itk::ComplexToComplexFFTImageFilter; auto inverseComplexFilter = ComplexFilterType::New(); + + // ITK_EXERCISE_BASIC_OBJECT_METHODS(inverseComplexFilter, ComplexToComplexFFTImageFilter, ImageToImageFilter); + + inverseComplexFilter->SetInput(forwardFilter->GetOutput()); inverseComplexFilter->SetTransformDirection(ComplexFilterType::TransformDirectionEnum::INVERSE); diff --git a/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx index 3e869733895..14e990c1f62 100644 --- a/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx @@ -48,6 +48,11 @@ transformImage(const char * inputImageFileName, const char * outputImageFileName using ComplexFilterType = itk::VnlComplexToComplexFFTImageFilter; auto inverseComplexFilter = ComplexFilterType::New(); + + // ITK_EXERCISE_BASIC_OBJECT_METHODS( + // inverseComplexFilter, VnlComplexToComplexFFTImageFilter, ComplexToComplexFFTImageFilter); + + inverseComplexFilter->SetInput(forwardFilter->GetOutput()); inverseComplexFilter->SetTransformDirection(ComplexFilterType::TransformDirectionEnum::INVERSE); diff --git a/Modules/Filtering/FastMarching/test/CMakeLists.txt b/Modules/Filtering/FastMarching/test/CMakeLists.txt index 638501716d2..2788d256f06 100644 --- a/Modules/Filtering/FastMarching/test/CMakeLists.txt +++ b/Modules/Filtering/FastMarching/test/CMakeLists.txt @@ -28,7 +28,7 @@ CreateTestDriver(ITKFastMarching "${ITKFastMarching-Test_LIBRARIES}" "${ITKFastM itk_add_test(NAME itkFastMarchingExtensionImageFilterTest COMMAND ITKFastMarchingTestDriver itkFastMarchingExtensionImageFilterTest) itk_add_test(NAME itkFastMarchingTest - COMMAND ITKFastMarchingTestDriver itkFastMarchingTest) + COMMAND ITKFastMarchingTestDriver itkFastMarchingTest 1.0 1.0 100.0 0 0 1.0 0.0 0) itk_add_test(NAME itkFastMarchingTest2 COMMAND ITKFastMarchingTestDriver itkFastMarchingTest2) itk_add_test(NAME itkFastMarchingUpwindGradientTest diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx index 5b59786adc6..402b4728231 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx @@ -19,6 +19,7 @@ #include "itkFastMarchingImageFilter.h" #include "itkTextOutput.h" #include "itkCommand.h" +#include "itkTestingMacros.h" namespace @@ -39,8 +40,17 @@ class ShowProgressObject } // namespace int -itkFastMarchingTest(int, char *[]) +itkFastMarchingTest(int argc, char * argv[]) { + if (argc != 9) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); + std::cerr << " speedConstant normalizationFactor stoppingValue collectPoints outputIndexValue outputSpacingValue " + "outputOriginValue overrideOutputInformation " + << std::endl; + return EXIT_FAILURE; + } itk::OutputWindow::SetInstance(itk::TextOutput::New().GetPointer()); @@ -51,6 +61,9 @@ itkFastMarchingTest(int, char *[]) auto marcher = FloatFMType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(marcher, FastMarchingImageFilter, ImageToImageFilter); + + ShowProgressObject progressWatch(marcher); itk::SimpleMemberCommand::Pointer command; command = itk::SimpleMemberCommand::New(); @@ -80,6 +93,7 @@ itkFastMarchingTest(int, char *[]) alivePoints->InsertElement(1, node); marcher->SetAlivePoints(alivePoints); + ITK_TEST_SET_GET_VALUE(alivePoints, marcher->GetAlivePoints()); // setup trial points @@ -115,10 +129,53 @@ itkFastMarchingTest(int, char *[]) trialPoints->InsertElement(4, node); marcher->SetTrialPoints(trialPoints); + ITK_TEST_SET_GET_VALUE(trialPoints, marcher->GetTrialPoints()); + + auto speedConstant = std::stod(argv[1]); + marcher->SetSpeedConstant(speedConstant); + ITK_TEST_SET_GET_VALUE(speedConstant, marcher->GetSpeedConstant()); + + auto normalizationFactor = std::stod(argv[2]); + marcher->SetNormalizationFactor(normalizationFactor); + ITK_TEST_SET_GET_VALUE(normalizationFactor, marcher->GetNormalizationFactor()); - // specify the size of the output image - FloatImage::SizeType size = { { 64, 64 } }; + auto stoppingValue = std::stod(argv[3]); + marcher->SetStoppingValue(stoppingValue); + ITK_TEST_SET_GET_VALUE(stoppingValue, marcher->GetStoppingValue()); + + auto collectPoints = static_cast(std::stoi(argv[4])); + ITK_TEST_SET_GET_BOOLEAN(marcher, CollectPoints, collectPoints); + + typename FloatImage::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); + ITK_TEST_SET_GET_VALUE(size, marcher->GetOutputSize()); + + auto outputRegionIndexValue = + static_cast(std::stoi(argv[5])); + typename FloatFMType::LevelSetImageType::IndexType outputRegionIndex{ outputRegionIndexValue }; + typename FloatFMType::OutputRegionType outputRegion; + outputRegion.SetSize(size); + outputRegion.SetIndex(outputRegionIndex); + marcher->SetOutputRegion(outputRegion); + ITK_TEST_SET_GET_VALUE(outputRegion, marcher->GetOutputRegion()); + + auto outputSpacingValue = static_cast(std::stod(argv[6])); + typename FloatFMType::OutputSpacingType outputSpacing(outputSpacingValue); + marcher->SetOutputSpacing(outputSpacing); + ITK_TEST_SET_GET_VALUE(outputSpacing, marcher->GetOutputSpacing()); + + typename FloatFMType::OutputDirectionType outputDirection; + outputDirection.SetIdentity(); + marcher->SetOutputDirection(outputDirection); + ITK_TEST_SET_GET_VALUE(outputDirection, marcher->GetOutputDirection()); + + auto outputOriginValue = static_cast(std::stod(argv[7])); + typename FloatFMType::OutputPointType outputOrigin(outputOriginValue); + marcher->SetOutputOrigin(outputOrigin); + ITK_TEST_SET_GET_VALUE(outputOrigin, marcher->GetOutputOrigin()); + + auto overrideOutputInformation = static_cast(std::stoi(argv[8])); + ITK_TEST_SET_GET_BOOLEAN(marcher, OverrideOutputInformation, overrideOutputInformation); // setup a speed image of ones auto speedImage = FloatImage::New(); @@ -134,9 +191,8 @@ itkFastMarchingTest(int, char *[]) speedIter.Set(1.0); } - speedImage->Print(std::cout); marcher->SetInput(speedImage); - marcher->SetStoppingValue(100.0); + ITK_TEST_SET_GET_VALUE(speedImage, marcher->GetInput()); // turn on debugging marcher->DebugOn(); @@ -181,20 +237,6 @@ itkFastMarchingTest(int, char *[]) } } - // Exercise other member functions - std::cout << "SpeedConstant: " << marcher->GetSpeedConstant() << std::endl; - std::cout << "StoppingValue: " << marcher->GetStoppingValue() << std::endl; - std::cout << "CollectPoints: " << marcher->GetCollectPoints() << std::endl; - - marcher->SetNormalizationFactor(2.0); - std::cout << "NormalizationFactor: " << marcher->GetNormalizationFactor(); - std::cout << std::endl; - - std::cout << "SpeedImage: " << marcher->GetInput(); - std::cout << std::endl; - - marcher->Print(std::cout); - // Test streaming enumeration for FastMarchingImageFilterEnums::Label elements const std::set allLabel{ itk::FastMarchingImageFilterEnums::Label::FarPoint, diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx index ea0ccb5ddda..5b7d23cff8d 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx @@ -214,20 +214,6 @@ itkFastMarchingTest2(int, char *[]) } } - // Exercise other member functions - std::cout << "SpeedConstant: " << marcher->GetSpeedConstant() << std::endl; - std::cout << "StoppingValue: " << marcher->GetStoppingValue() << std::endl; - std::cout << "CollectPoints: " << marcher->GetCollectPoints() << std::endl; - - marcher->SetNormalizationFactor(2.0); - std::cout << "NormalizationFactor: " << marcher->GetNormalizationFactor(); - std::cout << std::endl; - - std::cout << "SpeedImage: " << marcher->GetInput(); - std::cout << std::endl; - - marcher->Print(std::cout); - if (passed) { std::cout << "Fast Marching test passed" << std::endl; diff --git a/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx index 99c7a38081d..0a5b3acbf45 100644 --- a/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx @@ -18,6 +18,7 @@ #include "itkAbsoluteValueDifferenceImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" +#include "itkTestingMacros.h" int @@ -112,13 +113,15 @@ itkAbsoluteValueDifferenceImageFilterTest(int, char *[]) } - // Declare the type for the Magnitude Filter + // Declare the type for the filter using myFilterType = itk::AbsoluteValueDifferenceImageFilter; - // Create a MagnitudeImageFilter + // Create the filter auto filter = myFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, AbsoluteValueDifferenceImageFilter, BinaryGeneratorImageFilter); + // Connect the input images filter->SetInput1(inputImageA); diff --git a/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx index 97783fa1440..6d6a16a196d 100644 --- a/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx @@ -20,6 +20,7 @@ #include "itkRGBAPixel.h" #include "vnl/vnl_sample.h" #include "itkImageRegionIterator.h" +#include "itkTestingMacros.h" int itkJoinImageFilterTest(int, char *[]) @@ -148,6 +149,10 @@ itkJoinImageFilterTest(int, char *[]) // Setup a JoinImageFilter auto filter = myFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, JoinImageFilter, BinaryGeneratorImageFilter); + + filter->SetInput1(inputImageA); filter->SetInput2(inputImageB); diff --git a/Modules/Filtering/ImageFeature/test/Baseline/itkSobelEdgeDetectionImageFilterTestBaseline.png.sha512 b/Modules/Filtering/ImageFeature/test/Baseline/itkSobelEdgeDetectionImageFilterTestBaseline.png.sha512 new file mode 100644 index 00000000000..52ccc2318f5 --- /dev/null +++ b/Modules/Filtering/ImageFeature/test/Baseline/itkSobelEdgeDetectionImageFilterTestBaseline.png.sha512 @@ -0,0 +1 @@ +77ae7a0a585e2bc587574990512596eaa1f205de5c7a3a76cd75df3199c921a35702e4aa1849dc56e488163e70a8a2467b9d5c33a2d26f8b7687f60c4d7880fb diff --git a/Modules/Filtering/ImageFeature/test/CMakeLists.txt b/Modules/Filtering/ImageFeature/test/CMakeLists.txt index fbf780589bf..6648893fabd 100644 --- a/Modules/Filtering/ImageFeature/test/CMakeLists.txt +++ b/Modules/Filtering/ImageFeature/test/CMakeLists.txt @@ -50,7 +50,11 @@ itk_add_test(NAME itkLaplacianImageFilterWithSpacingTest ${ITK_TEST_OUTPUT_DIR}/itkLaplacianImageFilterWithSpacingTest.png 1) itk_add_test(NAME itkSobelEdgeDetectionImageFilterTest - COMMAND ITKImageFeatureTestDriver itkSobelEdgeDetectionImageFilterTest) + COMMAND ITKImageFeatureTestDriver + --compare DATA{Baseline/itkSobelEdgeDetectionImageFilterTestBaseline.png} + ${ITK_TEST_OUTPUT_DIR}/itkSobelEdgeDetectionImageFilterTest.png + itkSobelEdgeDetectionImageFilterTest + DATA{Input/Swirled.png} ${ITK_TEST_OUTPUT_DIR}/itkSobelEdgeDetectionImageFilterTest.png) itk_add_test(NAME itkUnsharpMaskImageFilterTestSimple COMMAND ITKImageFeatureTestDriver itkUnsharpMaskImageFilterTestSimple) itk_add_test(NAME itkUnsharpMaskImageFilterTest_DefaultsUChar @@ -108,7 +112,7 @@ itk_add_test(NAME itkHessianRecursiveGaussianFilterScaleSpaceTest itk_add_test(NAME itkHessianRecursiveGaussianFilterTest COMMAND ITKImageFeatureTestDriver --redirectOutput ${TEMP}/itkHessianRecursiveGaussianFilterTest.txt - itkHessianRecursiveGaussianFilterTest 0) + itkHessianRecursiveGaussianFilterTest 2.5 0) set_tests_properties(itkHessianRecursiveGaussianFilterTest PROPERTIES ATTACHED_FILES_ON_FAIL ${TEMP}/itkHessianRecursiveGaussianFilterTest.txt) itk_add_test(NAME itkHoughTransform2DCirclesImageTest @@ -176,7 +180,7 @@ itk_add_test(NAME itkMaskFeaturePointSelectionFilterTest --compare DATA{Baseline/itkMaskFeaturePointSelectionFilterTest.mha} ${ITK_TEST_OUTPUT_DIR}/itkMaskFeaturePointSelectionFilterTest.mha itkMaskFeaturePointSelectionFilterTest -DATA{${ITK_DATA_ROOT}/Input/HeadMRVolume.mha} ${ITK_TEST_OUTPUT_DIR}/itkMaskFeaturePointSelectionFilterTest.mha) +DATA{${ITK_DATA_ROOT}/Input/HeadMRVolume.mha} ${ITK_TEST_OUTPUT_DIR}/itkMaskFeaturePointSelectionFilterTest.mha 0 2 0 0.01) itk_add_test(NAME itkDiscreteGaussianDerivativeImageFilterScaleSpaceTest COMMAND ITKImageFeatureTestDriver itkDiscreteGaussianDerivativeImageFilterScaleSpaceTest) itk_add_test(NAME itkDiscreteGaussianDerivativeImageFilterTest01 diff --git a/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx index 6d3011bad50..5da968cdbde 100644 --- a/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx @@ -22,10 +22,10 @@ int itkHessianRecursiveGaussianFilterTest(int argc, char * argv[]) { - if (argc != 2) + if (argc != 3) { std::cerr << "Missing parameters." << std::endl; - std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " normalizeAcrossScale" << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " sigma normalizeAcrossScale" << std::endl; return EXIT_FAILURE; } @@ -107,19 +107,20 @@ itkHessianRecursiveGaussianFilterTest(int argc, char * argv[]) // Create a Filter - auto filter = myFilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + auto filter = myFilterType::New(); - auto normalizeAcrossScale = static_cast(std::stoi(argv[1])); - ITK_TEST_SET_GET_BOOLEAN(filter, NormalizeAcrossScale, normalizeAcrossScale); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, HessianRecursiveGaussianImageFilter, ImageToImageFilter); - // Connect the input images - filter->SetInput(inputImage); + auto sigma = static_cast(std::stod(argv[1])); + filter->SetSigma(sigma); + ITK_TEST_SET_GET_VALUE(sigma, filter->GetSigma()); - // Select the value of Sigma - filter->SetSigma(2.5); + auto normalizeAcrossScale = static_cast(std::stoi(argv[2])); + ITK_TEST_SET_GET_BOOLEAN(filter, NormalizeAcrossScale, normalizeAcrossScale); + // Connect the input images + filter->SetInput(inputImage); // Execute the filter filter->Update(); diff --git a/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx index 8b674bf2626..0e2d75721e9 100644 --- a/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx @@ -32,10 +32,10 @@ int itkMaskFeaturePointSelectionFilterTest(int argc, char * argv[]) { - if (argc < 2) + if (argc < 6) { - std::cerr << "Usage: " << std::endl; - std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImageFile outputImageFile [Mask File] "; + std::cerr << itkNameOfTestExecutableMacro(argv) + << " inputImageFile outputImageFile nonConnectivity blockRadius computeStructureTensors selectFraction"; return EXIT_FAILURE; } @@ -59,12 +59,27 @@ itkMaskFeaturePointSelectionFilterTest(int argc, char * argv[]) // Set up filter auto filter = FilterType::New(); - filter->SetInput(reader->GetOutput()); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MaskFeaturePointSelectionFilter, ImageToMeshFilter); + + + auto nonConnectivity = static_cast(std::stoi(argv[3])); + filter->SetNonConnectivity(nonConnectivity); + ITK_TEST_SET_GET_VALUE(nonConnectivity, filter->GetNonConnectivity()); - filter->SetSelectFraction(0.01); - filter->ComputeStructureTensorsOff(); + auto blockRadiusValue = static_cast(std::stod(argv[4])); + typename FilterType::SizeType blockRadius; + blockRadius.Fill(blockRadiusValue); + filter->SetBlockRadius(blockRadius); + ITK_TEST_SET_GET_VALUE(blockRadius, filter->GetBlockRadius()); - std::cout << "Filter: " << filter << std::endl; + auto computeStructureTensors = static_cast(std::stoi(argv[5])); + ITK_TEST_SET_GET_BOOLEAN(filter, ComputeStructureTensors, computeStructureTensors); + + auto selectFraction = std::stod(argv[6]); + filter->SetSelectFraction(selectFraction); + ITK_TEST_SET_GET_VALUE(selectFraction, filter->GetSelectFraction()); + + filter->SetInput(reader->GetOutput()); try { diff --git a/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx index 40c1efefb06..ad7f441844c 100644 --- a/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx @@ -83,8 +83,14 @@ itkMultiScaleHessianBasedMeasureImageFilterTest(int argc, char * argv[]) auto multiScaleEnhancementFilter = MultiScaleEnhancementFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS( + multiScaleEnhancementFilter, MultiScaleHessianBasedMeasureImageFilter, ImageToImageFilter); + + multiScaleEnhancementFilter->SetInput(imageReader->GetOutput()); multiScaleEnhancementFilter->SetHessianToMeasureFilter(objectnessFilter); + ITK_TEST_SET_GET_VALUE(objectnessFilter, multiScaleEnhancementFilter->GetHessianToMeasureFilter()); + multiScaleEnhancementFilter->SetSigmaStepMethodToLogarithmic(); itk::SimpleFilterWatcher watcher(multiScaleEnhancementFilter); @@ -166,6 +172,10 @@ itkMultiScaleHessianBasedMeasureImageFilterTest(int argc, char * argv[]) } multiScaleEnhancementFilter->SetGenerateHessianOutput(true); + bool nonNegativeHessianBasedMeasure = true; + ITK_TEST_SET_GET_BOOLEAN(multiScaleEnhancementFilter, NonNegativeHessianBasedMeasure, nonNegativeHessianBasedMeasure); + + try { multiScaleEnhancementFilter->Update(); @@ -207,14 +217,13 @@ itkMultiScaleHessianBasedMeasureImageFilterTest(int argc, char * argv[]) std::cout << "Hessian Image Buffered Region = " << std::endl; std::cout << hessianImage->GetBufferedRegion() << std::endl; - // Print out - multiScaleEnhancementFilter->Print(std::cout); - if (argc > 9) { // Change sigma step to equispaced type and regnerate vesselness image - multiScaleEnhancementFilter->SetSigmaStepMethod( + auto sigmaStepMethod = static_cast( MultiScaleEnhancementFilterType::SigmaStepMethodEnum::EquispacedSigmaSteps); + multiScaleEnhancementFilter->SetSigmaStepMethod(sigmaStepMethod); + ITK_TEST_SET_GET_VALUE(sigmaStepMethod, multiScaleEnhancementFilter->GetSigmaStepMethod()); try { @@ -243,9 +252,9 @@ itkMultiScaleHessianBasedMeasureImageFilterTest(int argc, char * argv[]) if (argc > 10) { // Change NonNegativeHessianBasedMeasure to Off and regnerate vesselness image - multiScaleEnhancementFilter->NonNegativeHessianBasedMeasureOff(); - - multiScaleEnhancementFilter->Print(std::cout); + nonNegativeHessianBasedMeasure = false; + ITK_TEST_SET_GET_BOOLEAN( + multiScaleEnhancementFilter, NonNegativeHessianBasedMeasure, nonNegativeHessianBasedMeasure); try { diff --git a/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx index e5060ca7d3a..6a96703610e 100644 --- a/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx @@ -16,41 +16,50 @@ * *=========================================================================*/ -#include +#include "itkImageFileReader.h" +#include "itkImageFileWriter.h" +#include "itkRescaleIntensityImageFilter.h" #include "itkSobelEdgeDetectionImageFilter.h" -#include "itkNullImageToImageFilterDriver.hxx" +#include "itkTestingMacros.h" -inline std::ostream & -operator<<(std::ostream & o, const itk::Vector & v) -{ - o << "[" << v[0] << " " << v[1] << " " << v[2] << "]"; - return o; -} int -itkSobelEdgeDetectionImageFilterTest(int, char *[]) +itkSobelEdgeDetectionImageFilterTest(int argc, char * argv[]) { - try - { - using ImageType = itk::Image; - - // Set up filter - itk::SobelEdgeDetectionImageFilter::Pointer filter = - itk::SobelEdgeDetectionImageFilter::New(); - - // Run Test - itk::Size<2> sz; - sz[0] = 100; - sz[1] = 100; - itk::NullImageToImageFilterDriver test1; - test1.SetImageSize(sz); - test1.SetFilter(filter); - test1.Execute(); - } - catch (const itk::ExceptionObject & err) + if (argc != 3) { - (&err)->Print(std::cerr); + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFilename outputFilename" << std::endl; return EXIT_FAILURE; } + + constexpr unsigned int Dimension = 2; + using InputPixelType = unsigned char; + using OutputPixelType = float; + + using InputImageType = itk::Image; + using OutputImageType = itk::Image; + + itk::SobelEdgeDetectionImageFilter::Pointer filter = + itk::SobelEdgeDetectionImageFilter::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, SobelEdgeDetectionImageFilter, ImageToImageFilter); + + InputImageType::Pointer inputImagePtr; + ITK_TRY_EXPECT_NO_EXCEPTION(inputImagePtr = itk::ReadImage(argv[1])); + + filter->SetInput(inputImagePtr); + + ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); + + using RescaleIntensityImageFilterFilterType = itk::RescaleIntensityImageFilter; + auto rescaler = RescaleIntensityImageFilterFilterType::New(); + rescaler->SetInput(filter->GetOutput()); + + + ITK_TRY_EXPECT_NO_EXCEPTION(itk::WriteImage(rescaler->GetOutput(), argv[2])); + + + std::cout << "Test finished." << std::endl; return EXIT_SUCCESS; } diff --git a/Modules/Filtering/ImageGradient/test/CMakeLists.txt b/Modules/Filtering/ImageGradient/test/CMakeLists.txt index 4cfbcb723ed..6c7be541095 100644 --- a/Modules/Filtering/ImageGradient/test/CMakeLists.txt +++ b/Modules/Filtering/ImageGradient/test/CMakeLists.txt @@ -54,7 +54,7 @@ itk_add_test(NAME itkVectorGradientMagnitudeImageFilterTest3 COMMAND ITKImageGradientTestDriver itkVectorGradientMagnitudeImageFilterTest3 DATA{${ITK_DATA_ROOT}/Input/VHFColor.mhd,VHFColor.raw} ${ITK_TEST_OUTPUT_DIR}/VectorGradientMagnitudeImageFilterTest3.mha 1) itk_add_test(NAME itkGradientMagnitudeRecursiveGaussianFilterTest - COMMAND ITKImageGradientTestDriver itkGradientMagnitudeRecursiveGaussianFilterTest 0) + COMMAND ITKImageGradientTestDriver itkGradientMagnitudeRecursiveGaussianFilterTest 2.5 0) itk_add_test(NAME itkGradientRecursiveGaussianFilterTest COMMAND ITKImageGradientTestDriver itkGradientRecursiveGaussianFilterTest) itk_add_test(NAME itkGradientRecursiveGaussianFilterTest2 diff --git a/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx b/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx index f5909dd42fa..34d0392531d 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx @@ -46,10 +46,10 @@ class ImageInformationIsEqual int itkGradientMagnitudeRecursiveGaussianFilterTest(int argc, char * argv[]) { - if (argc != 2) + if (argc != 3) { std::cerr << "Missing parameters." << std::endl; - std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " normalizeAcrossScale" << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " sigma normalizeAcrossScale" << std::endl; return EXIT_FAILURE; } @@ -149,19 +149,23 @@ itkGradientMagnitudeRecursiveGaussianFilterTest(int argc, char * argv[]) // Create a Filter - auto filter = myFilterType::New(); + auto filter = myFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GradientMagnitudeRecursiveGaussianImageFilter, InPlaceImageFilter); + + itk::SimpleFilterWatcher watcher(filter); - auto normalizeAcrossScale = static_cast(std::stoi(argv[1])); + auto sigma = static_cast(std::stod(argv[1])); + filter->SetSigma(sigma); + ITK_TEST_SET_GET_VALUE(sigma, filter->GetSigma()); + + auto normalizeAcrossScale = static_cast(std::stoi(argv[2])); ITK_TEST_SET_GET_BOOLEAN(filter, NormalizeAcrossScale, normalizeAcrossScale); // Connect the input images filter->SetInput(inputImage); - // Select the value of Sigma - filter->SetSigma(2.5); - - // Execute the filter try { diff --git a/Modules/Filtering/ImageGrid/test/CMakeLists.txt b/Modules/Filtering/ImageGrid/test/CMakeLists.txt index 2dcc45a94f1..25368455289 100644 --- a/Modules/Filtering/ImageGrid/test/CMakeLists.txt +++ b/Modules/Filtering/ImageGrid/test/CMakeLists.txt @@ -195,7 +195,7 @@ itk_add_test(NAME itkOrientedImageProfileTest2 itk_add_test(NAME itkOrientedImageProfileTest3 COMMAND ITKImageGridTestDriver itkOrientedImageProfileTest3) itk_add_test(NAME itkOrientImageFilterTest - COMMAND ITKImageGridTestDriver 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/itkMirrorPadImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkMirrorPadImageFilterTest.cxx index d88c88d65a5..f12da4a7a00 100644 --- a/Modules/Filtering/ImageGrid/test/itkMirrorPadImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkMirrorPadImageFilterTest.cxx @@ -45,10 +45,14 @@ RunTest(int argc, char * argv[]) using Mirror = itk::MirrorPadImageFilter; auto filter = Mirror::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MirrorPadImageFilter, PadImageFilter); + + if (argc > 4) { double decayFactor = std::stod(argv[4]); filter->SetDecayBase(decayFactor); + ITK_TEST_SET_GET_VALUE(decayFactor, filter->GetDecayBase()); } typename OutImageType::SizeType pad; diff --git a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx index dc636aa3e4d..5bb90a7ebc0 100644 --- a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx @@ -64,8 +64,15 @@ PrintImg(ImageType::Pointer img) } int -itkOrientImageFilterTest(int, char *[]) +itkOrientImageFilterTest(int argc, char * argv[]) { + if (argc != 2) + { + std::cerr << "Missing Parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " useImageDirection" << std::endl; + return EXIT_FAILURE; + } + itk::MultiThreaderBase::SetGlobalMaximumNumberOfThreads(1); ImageType::Pointer randImage = CreateRandomImage(); std::cerr << "Original" << std::endl; @@ -75,6 +82,10 @@ itkOrientImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(orienter, OrientImageFilter, ImageToImageFilter); + + auto useImageDirection = static_cast(std::stoi(argv[1])); + ITK_TEST_SET_GET_BOOLEAN(orienter, UseImageDirection, useImageDirection); + orienter->SetGivenCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP); orienter->SetInput(randImage); diff --git a/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx index 3cceba15726..c7e35e64632 100644 --- a/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx @@ -21,6 +21,7 @@ #include "itkWarpVectorImageFilter.h" #include "itkCastImageFilter.h" #include "itkStreamingImageFilter.h" +#include "itkTestingMacros.h" // class to produce a linear image pattern template @@ -171,9 +172,15 @@ itkWarpVectorImageFilterTest(int, char *[]) using WarperType = itk::WarpVectorImageFilter; auto warper = WarperType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(warper, WarpVectorImageFilter, ImageToImageFilter); + + warper->SetInput(input); warper->SetDisplacementField(field); + ITK_TEST_SET_GET_VALUE(field, warper->GetDisplacementField()); + warper->SetEdgePaddingValue(PixelType(padValue)); + ITK_TEST_SET_GET_VALUE(PixelType(padValue), warper->GetEdgePaddingValue()); ShowProgressObject progressWatch(warper); itk::SimpleMemberCommand::Pointer command; @@ -181,24 +188,27 @@ itkWarpVectorImageFilterTest(int, char *[]) command->SetCallbackFunction(&progressWatch, &ShowProgressObject::ShowProgress); warper->AddObserver(itk::ProgressEvent(), command); - warper->Print(std::cout); - - // exercise Get methods - std::cout << "Interpolator: " << warper->GetInterpolator() << std::endl; - std::cout << "DisplacementField: " << warper->GetDisplacementField() << std::endl; - std::cout << "EdgePaddingValue: " << warper->GetEdgePaddingValue() << std::endl; - - // exercise Set methods itk::FixedArray array; array.Fill(2.0); warper->SetOutputSpacing(array.GetDataPointer()); + ITK_TEST_SET_GET_VALUE(array, warper->GetOutputSpacing()); + array.Fill(1.0); warper->SetOutputSpacing(array.GetDataPointer()); + ITK_TEST_SET_GET_VALUE(array, warper->GetOutputSpacing()); array.Fill(-10.0); warper->SetOutputOrigin(array.GetDataPointer()); + ITK_TEST_SET_GET_VALUE(array, warper->GetOutputOrigin()); + array.Fill(0.0); warper->SetOutputOrigin(array.GetDataPointer()); + ITK_TEST_SET_GET_VALUE(array, warper->GetOutputOrigin()); + + typename WarperType::DirectionType outputDirection; + outputDirection.SetIdentity(); + warper->SetOutputDirection(outputDirection); + ITK_TEST_SET_GET_VALUE(outputDirection, warper->GetOutputDirection()); // Update the filter warper->Update(); @@ -355,6 +365,7 @@ itkWarpVectorImageFilterTest(int, char *[]) testPassed = true; warper->ResetPipeline(); warper->SetInterpolator(interp); + ITK_TEST_SET_GET_VALUE(interp, warper->GetInterpolator()); } if (!testPassed) diff --git a/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx index 147d9dfdb37..f7ac554393d 100644 --- a/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx @@ -20,6 +20,7 @@ #include "itkMath.h" #include "itkZeroFluxNeumannPadImageFilter.h" #include "itkStreamingImageFilter.h" +#include "itkTestingMacros.h" using ShortImage = itk::Image; using FloatImage = itk::Image; @@ -193,6 +194,10 @@ itkZeroFluxNeumannPadImageFilterTest(int, char *[]) // Create a filter auto padFilter = FilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(padFilter, ZeroFluxNeumannPadImageFilter, PadImageFilter); + + padFilter->SetInput(inputImage); // itk::SimpleFilterWatcher watcher( padFilter ); diff --git a/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx index 2a4fec5da32..0f6daf8c920 100644 --- a/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx @@ -18,6 +18,7 @@ #include "itkVectorMagnitudeImageFilter.h" #include "itkImageRegionIterator.h" +#include "itkTestingMacros.h" int itkVectorMagnitudeImageFilterTest(int, char *[]) @@ -62,6 +63,9 @@ itkVectorMagnitudeImageFilterTest(int, char *[]) // Create the filter auto magnitude = myMagnitudeFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(magnitude, VectorMagnitudeImageFilter, UnaryGeneratorImageFilter); + + magnitude->SetInput(image); // Now compute the magnitude of the gradient diff --git a/Modules/Filtering/ImageStatistics/test/CMakeLists.txt b/Modules/Filtering/ImageStatistics/test/CMakeLists.txt index bc705713c41..1f97609de05 100644 --- a/Modules/Filtering/ImageStatistics/test/CMakeLists.txt +++ b/Modules/Filtering/ImageStatistics/test/CMakeLists.txt @@ -42,17 +42,17 @@ itk_add_test(NAME itkStatisticsImageFilterTest_3 itk_add_test(NAME itkLabelStatisticsImageFilterTest_1 COMMAND ITKImageStatisticsTestDriver itkLabelStatisticsImageFilterTest DATA{${ITK_DATA_ROOT}/Input/peppers.png} - DATA{${ITK_DATA_ROOT}/Baseline/Algorithms/OtsuMultipleThresholdsImageFilterTest.png}) + DATA{${ITK_DATA_ROOT}/Baseline/Algorithms/OtsuMultipleThresholdsImageFilterTest.png} 1) itk_add_test(NAME itkLabelStatisticsImageFilterTest_2 COMMAND ITKImageStatisticsTestDriver itkLabelStatisticsImageFilterTest DATA{${ITK_DATA_ROOT}/Input/peppers.png} DATA{${ITK_DATA_ROOT}/Baseline/Algorithms/OtsuMultipleThresholdsImageFilterTest.png} - 10 ) + 1 10 ) itk_add_test(NAME itkLabelStatisticsImageFilterTest_3 COMMAND ITKImageStatisticsTestDriver itkLabelStatisticsImageFilterTest DATA{${ITK_DATA_ROOT}/Input/peppers.png} DATA{${ITK_DATA_ROOT}/Baseline/Algorithms/OtsuMultipleThresholdsImageFilterTest.png} - 20 ) + 1 20 ) itk_add_test(NAME itkSumProjectionImageFilterTest COMMAND ITKImageStatisticsTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/HeadMRVolumeSumProjection.tif} @@ -68,7 +68,7 @@ itk_add_test(NAME itkImageMomentsNoMaskTest itk_add_test(NAME itkImageMomentsWithMaskTest COMMAND ITKImageStatisticsTestDriver itkImageMomentsTest mask) itk_add_test(NAME itkMinimumMaximumImageFilterTest - COMMAND ITKImageStatisticsTestDriver itkMinimumMaximumImageFilterTest) + COMMAND ITKImageStatisticsTestDriver itkMinimumMaximumImageFilterTest 1) itk_add_test(NAME itkImagePCAShapeModelEstimatorTest COMMAND ITKImageStatisticsTestDriver itkImagePCAShapeModelEstimatorTest) itk_add_test(NAME itkMaximumProjectionImageFilterTest2_1 @@ -157,7 +157,7 @@ itk_add_test(NAME itkGetAverageSliceImageFilterTest COMMAND ITKImageStatisticsTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/AccumulateImageFilterTest.png} ${ITK_TEST_OUTPUT_DIR}/GetAverageSliceImageFilterTest.png - itkGetAverageSliceImageFilterTest DATA{${ITK_DATA_ROOT}/Input/DicomSeries/,REGEX:Image[0-9]+.dcm} ${ITK_TEST_OUTPUT_DIR}/GetAverageSliceImageFilterTest.png) + itkGetAverageSliceImageFilterTest DATA{${ITK_DATA_ROOT}/Input/DicomSeries/,REGEX:Image[0-9]+.dcm} ${ITK_TEST_OUTPUT_DIR}/GetAverageSliceImageFilterTest.png 2) itk_add_test(NAME itkBinaryProjectionImageFilterTest1 COMMAND ITKImageStatisticsTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/HeadMRVolumeBinaryProjection100.tif} diff --git a/Modules/Filtering/ImageStatistics/test/itkGetAverageSliceImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkGetAverageSliceImageFilterTest.cxx index 4ce3dac697c..b133f8fa818 100644 --- a/Modules/Filtering/ImageStatistics/test/itkGetAverageSliceImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkGetAverageSliceImageFilterTest.cxx @@ -38,10 +38,11 @@ itkGetAverageSliceImageFilterTest(int argc, char * argv[]) using SeriesFileNames = itk::GDCMSeriesFileNames; using ImageIOType = itk::GDCMImageIO; - if (argc < 3) + if (argc < 4) { std::cerr << "Usage: " << std::endl; - std::cerr << itkNameOfTestExecutableMacro(argv) << " inputDICOMDirectory outputFile" << std::endl; + std::cerr << itkNameOfTestExecutableMacro(argv) << " inputDICOMDirectory outputFile averagedOutDimension" + << std::endl; return EXIT_FAILURE; } @@ -69,8 +70,13 @@ itkGetAverageSliceImageFilterTest(int argc, char * argv[]) // GetAverage the input images auto average = GetAveragerType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(average, GetAverageSliceImageFilter, AccumulateImageFilter); + + auto averagedOutDimension = static_cast(std::stoi(argv[3])); + average->SetAveragedOutDimension(averagedOutDimension); + ITK_TEST_SET_GET_VALUE(averagedOutDimension, average->GetAveragedOutDimension()); + average->SetInput(reader->GetOutput()); - average->SetAveragedOutDimension(2); try { diff --git a/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx index 01644b61a33..e5278c343d4 100644 --- a/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx @@ -30,11 +30,12 @@ itkLabelStatisticsImageFilterTest(int argc, char * argv[]) { std::cout << "itkLabelStatisticsImageFilterTest Start" << std::endl; - if (argc < 3) + if (argc < 4) { std::cerr << "Missing Arguments" << std::endl; std::cerr << "Usage: " << std::endl; - std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImage labeledImage [numberOfStreamDivision]" << std::endl; + std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImage labeledImage useHistograms [numberOfStreamDivision]" + << std::endl; return EXIT_FAILURE; } using ImageType = itk::Image; @@ -50,9 +51,9 @@ itkLabelStatisticsImageFilterTest(int argc, char * argv[]) unsigned int numberOfStreamDivisions = 1; - if (argc > 3) + if (argc > 4) { - numberOfStreamDivisions = std::max(std::stoi(argv[3]), 1); + numberOfStreamDivisions = std::max(std::stoi(argv[4]), 1); } using FilterType = itk::LabelStatisticsImageFilter; @@ -64,10 +65,15 @@ itkLabelStatisticsImageFilterTest(int argc, char * argv[]) itk::SimpleFilterWatcher filterWatch(filter); + auto useHistograms = static_cast(std::stoi(argv[3])); + ITK_TEST_SET_GET_BOOLEAN(filter, UseHistograms, useHistograms); + + filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); + ITK_TEST_SET_GET_VALUE(numberOfStreamDivisions, filter->GetNumberOfStreamDivisions()); + filter->SetInput(reader1->GetOutput()); filter->SetLabelInput(reader2->GetOutput()); - filter->UseHistogramsOn(); - filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); + try { filter->Update(); diff --git a/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx index 3e6042e64b5..eaf0d6a4656 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx @@ -23,8 +23,15 @@ #include "itkTestingMacros.h" int -itkMinimumMaximumImageFilterTest(int, char *[]) +itkMinimumMaximumImageFilterTest(int argc, char * argv[]) { + if (argc != 2) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " numberOfStreamDivisions" << std::endl; + return EXIT_FAILURE; + } + using SizeType = itk::Size<3>; using ImageType = itk::Image; using MinMaxFilterType = itk::MinimumMaximumImageFilter; @@ -85,6 +92,10 @@ itkMinimumMaximumImageFilterTest(int, char *[]) itk::SimpleFilterWatcher watcher(filter); + const auto numberOfStreamDivisions = static_cast(std::stoi(argv[1])); + filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); + ITK_TEST_SET_GET_VALUE(numberOfStreamDivisions, filter->GetNumberOfStreamDivisions()); + filter->SetInput(image); filter->Update(); diff --git a/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx index ddc2da1d8f2..7533220388a 100644 --- a/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx @@ -73,8 +73,10 @@ itkStatisticsImageFilterTest(int argc, char * argv[]) itk::SimpleFilterWatcher filterWatch(filter); - filter->SetInput(image); filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); + ITK_TEST_SET_GET_VALUE(numberOfStreamDivisions, filter->GetNumberOfStreamDivisions()); + + filter->SetInput(image); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Filtering/LabelMap/test/CMakeLists.txt b/Modules/Filtering/LabelMap/test/CMakeLists.txt index 3547e058d5c..d99d80d5184 100644 --- a/Modules/Filtering/LabelMap/test/CMakeLists.txt +++ b/Modules/Filtering/LabelMap/test/CMakeLists.txt @@ -192,12 +192,12 @@ itk_add_test(NAME itkBinaryReconstructionByDilationImageFilterTest COMMAND ITKLabelMapTestDriver --compare DATA{Baseline/itkBinaryReconstructionByDilationImageFilterTest.png} ${ITK_TEST_OUTPUT_DIR}/itkBinaryReconstructionByDilationImageFilterTest.png - itkBinaryReconstructionByDilationImageFilterTest DATA{${ITK_DATA_ROOT}/Input/SpotsInverted.png} DATA{${ITK_DATA_ROOT}/Input/Spots-markers.png} ${ITK_TEST_OUTPUT_DIR}/itkBinaryReconstructionByDilationImageFilterTest.png 255 100) + itkBinaryReconstructionByDilationImageFilterTest DATA{${ITK_DATA_ROOT}/Input/SpotsInverted.png} DATA{${ITK_DATA_ROOT}/Input/Spots-markers.png} ${ITK_TEST_OUTPUT_DIR}/itkBinaryReconstructionByDilationImageFilterTest.png 255 100 0) itk_add_test(NAME itkBinaryReconstructionByErosionImageFilterTest COMMAND ITKLabelMapTestDriver --compare DATA{Baseline/itkBinaryReconstructionByErosionImageFilterTest.png} ${ITK_TEST_OUTPUT_DIR}/itkBinaryReconstructionByErosionImageFilterTest.png - itkBinaryReconstructionByErosionImageFilterTest DATA{${ITK_DATA_ROOT}/Input/SpotsLabeled.png} DATA{${ITK_DATA_ROOT}/Input/Spots-markers.png} ${ITK_TEST_OUTPUT_DIR}/itkBinaryReconstructionByErosionImageFilterTest.png 0 255) + itkBinaryReconstructionByErosionImageFilterTest DATA{${ITK_DATA_ROOT}/Input/SpotsLabeled.png} DATA{${ITK_DATA_ROOT}/Input/Spots-markers.png} ${ITK_TEST_OUTPUT_DIR}/itkBinaryReconstructionByErosionImageFilterTest.png 0 255 0) itk_add_test(NAME itkBinaryReconstructionLabelMapFilterTest COMMAND ITKLabelMapTestDriver --compare DATA{Baseline/itkBinaryReconstructionLabelMapFilterTest.png} diff --git a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx index 535d58d7dc6..e7cced61b54 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx @@ -25,11 +25,11 @@ int itkBinaryReconstructionByDilationImageFilterTest(int argc, char * argv[]) { - if (argc != 6) + if (argc != 7) { std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); std::cerr << " input marker output"; - std::cerr << " fg bg"; + std::cerr << " fg bg fullyConnected"; std::cerr << std::endl; return EXIT_FAILURE; } @@ -50,6 +50,8 @@ itkBinaryReconstructionByDilationImageFilterTest(int argc, char * argv[]) using LabelReconstructionType = itk::BinaryReconstructionByDilationImageFilter; auto reconstruction = LabelReconstructionType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(reconstruction, BinaryReconstructionByDilationImageFilter, ImageToImageFilter); + // testing get and set macros for Lambda int fg = std::stoi(argv[4]); reconstruction->SetForegroundValue(fg); @@ -59,6 +61,9 @@ itkBinaryReconstructionByDilationImageFilterTest(int argc, char * argv[]) reconstruction->SetBackgroundValue(bg); ITK_TEST_SET_GET_VALUE(bg, reconstruction->GetBackgroundValue()); + auto fullyConnected = static_cast(std::stoi(argv[6])); + ITK_TEST_SET_GET_BOOLEAN(reconstruction, FullyConnected, fullyConnected); + reconstruction->SetMaskImage(reader->GetOutput()); reconstruction->SetInput("MaskImage", reader->GetOutput()); reconstruction->SetMarkerImage(reader2->GetOutput()); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx index 80c1c70d895..8ab7c1eaab7 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx @@ -25,10 +25,10 @@ int itkBinaryReconstructionByErosionImageFilterTest(int argc, char * argv[]) { - if (argc != 6) + if (argc != 7) { std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); - std::cerr << " mask marker output fg bg"; + std::cerr << " mask marker output fg bg fullyConnected"; std::cerr << std::endl; return EXIT_FAILURE; } @@ -49,6 +49,9 @@ itkBinaryReconstructionByErosionImageFilterTest(int argc, char * argv[]) using LabelReconstructionType = itk::BinaryReconstructionByErosionImageFilter; auto reconstruction = LabelReconstructionType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(reconstruction, BinaryReconstructionByErosionImageFilter, ImageToImageFilter); + + // testing get and set macros for Lambda int fg = std::stoi(argv[4]); reconstruction->SetForegroundValue(fg); @@ -58,6 +61,10 @@ itkBinaryReconstructionByErosionImageFilterTest(int argc, char * argv[]) reconstruction->SetBackgroundValue(bg); ITK_TEST_SET_GET_VALUE(bg, reconstruction->GetBackgroundValue()); + auto fullyConnected = static_cast(std::stoi(argv[6])); + ITK_TEST_SET_GET_BOOLEAN(reconstruction, FullyConnected, fullyConnected); + + reconstruction->SetMaskImage(reader->GetOutput()); reconstruction->SetInput("MaskImage", reader->GetOutput()); reconstruction->SetMarkerImage(reader2->GetOutput()); diff --git a/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx b/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx index 3b498013204..a819c863f86 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx @@ -20,6 +20,7 @@ #include "itkImage.h" #include "itkLabelImageToShapeLabelMapFilter.h" +#include "itkTestingMacros.h" namespace Math = itk::Math; @@ -96,6 +97,27 @@ class ShapeLabelMapFixture : public ::testing::Test } return false; } + + static bool + TestBasicObjectProperties() + { + using L2SType = itk::LabelImageToShapeLabelMapFilter; + auto l2s = L2SType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(l2s, LabelImageToShapeLabelMapFilter, ImageToImageFilter); + + + auto computeFeretDiameter = true; + ITK_TEST_SET_GET_BOOLEAN(l2s, ComputeFeretDiameter, computeFeretDiameter); + + auto computePerimeter = true; + ITK_TEST_SET_GET_BOOLEAN(l2s, ComputePerimeter, computePerimeter); + + auto computeOrientedBoundingBox = true; + ITK_TEST_SET_GET_BOOLEAN(l2s, ComputeOrientedBoundingBox, computeOrientedBoundingBox); + + return EXIT_SUCCESS; + } }; }; } // namespace @@ -105,6 +127,12 @@ class ShapeLabelMapFixture : public ::testing::Test // case the baseline value was just what was computed by the method. +TEST_F(ShapeLabelMapFixture, BasicObjectProperties) +{ + FixtureUtilities<2>::TestBasicObjectProperties(); + FixtureUtilities<3>::TestBasicObjectProperties(); +} + TEST_F(ShapeLabelMapFixture, 3D_T1x1x1) { using namespace itk::GTest::TypedefsAndConstructors::Dimension3; diff --git a/Modules/Filtering/MathematicalMorphology/test/CMakeLists.txt b/Modules/Filtering/MathematicalMorphology/test/CMakeLists.txt index 65691e56503..9055097db53 100644 --- a/Modules/Filtering/MathematicalMorphology/test/CMakeLists.txt +++ b/Modules/Filtering/MathematicalMorphology/test/CMakeLists.txt @@ -138,17 +138,17 @@ itk_add_test(NAME itkGrayscaleMorphologicalClosingImageFilterTest COMMAND ITKMathematicalMorphologyTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/GrayscaleMorphologicalClosingImageFilterTest.png} ${ITK_TEST_OUTPUT_DIR}/GrayscaleMorphologicalClosingImageFilterTest.png - itkGrayscaleMorphologicalClosingImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cthead1.png} ${ITK_TEST_OUTPUT_DIR}/GrayscaleMorphologicalClosingImageFilterTest.png) + itkGrayscaleMorphologicalClosingImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cthead1.png} ${ITK_TEST_OUTPUT_DIR}/GrayscaleMorphologicalClosingImageFilterTest.png 1) itk_add_test(NAME itkGrayscaleMorphologicalOpeningImageFilterTest COMMAND ITKMathematicalMorphologyTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/GrayscaleMorphologicalOpeningImageFilterTest.png} ${ITK_TEST_OUTPUT_DIR}/GrayscaleMorphologicalOpeningImageFilterTest.png - itkGrayscaleMorphologicalOpeningImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cthead1.png} ${ITK_TEST_OUTPUT_DIR}/GrayscaleMorphologicalOpeningImageFilterTest.png) + itkGrayscaleMorphologicalOpeningImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cthead1.png} ${ITK_TEST_OUTPUT_DIR}/GrayscaleMorphologicalOpeningImageFilterTest.png 1) itk_add_test(NAME itkGrayscaleGeodesicErodeDilateImageFilterTest COMMAND ITKMathematicalMorphologyTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/HMaximaMinimaImageFilterTest.png} ${ITK_TEST_OUTPUT_DIR}/itkGrayscaleGeodesicErodeDilateImageFilterTest.png - itkGrayscaleGeodesicErodeDilateImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cake_easy.png} ${ITK_TEST_OUTPUT_DIR}/itkGrayscaleGeodesicErodeDilateImageFilterTest.png 35) + itkGrayscaleGeodesicErodeDilateImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cake_easy.png} ${ITK_TEST_OUTPUT_DIR}/itkGrayscaleGeodesicErodeDilateImageFilterTest.png 35 1 0) itk_add_test(NAME itkGrayscaleGrindPeakImageFilterTest COMMAND ITKMathematicalMorphologyTestDriver --compare DATA{Baseline/itkGrayscaleGrindPeakImageFilterTest.png} @@ -247,13 +247,13 @@ itk_add_test(NAME itkDoubleThresholdImageFilterTest --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/DoubleThresholdImageFilterTest.png} ${ITK_TEST_OUTPUT_DIR}/DoubleThresholdImageFilterTest.png itkDoubleThresholdImageFilterTest ${ITK_EXAMPLE_DATA_ROOT}/BrainProtonDensitySlice.png - ${ITK_TEST_OUTPUT_DIR}/DoubleThresholdImageFilterTest.png 217 246 255 255) + ${ITK_TEST_OUTPUT_DIR}/DoubleThresholdImageFilterTest.png 217 246 255 255 0) itk_add_test(NAME itkDoubleThresholdImageFilterTest2 COMMAND ITKMathematicalMorphologyTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/DoubleThresholdImageFilterTest2.png} ${ITK_TEST_OUTPUT_DIR}/DoubleThresholdImageFilterTest2.png itkDoubleThresholdImageFilterTest ${ITK_EXAMPLE_DATA_ROOT}/BrainProtonDensitySlice.png - ${ITK_TEST_OUTPUT_DIR}/DoubleThresholdImageFilterTest2.png 150 164 164 180) + ${ITK_TEST_OUTPUT_DIR}/DoubleThresholdImageFilterTest2.png 150 164 164 180 0) itk_add_test(NAME itkRemoveBoundaryObjectsTest COMMAND ITKMathematicalMorphologyTestDriver --compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/RemoveBoundaryObjectsTest.png} diff --git a/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx index 5986a1dffa7..20a9a78e4e2 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx @@ -29,11 +29,11 @@ int itkDoubleThresholdImageFilterTest(int argc, char * argv[]) { - if (argc < 7) + if (argc < 8) { std::cerr << "Usage: " << std::endl; std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImageFile "; - std::cerr << " outputImageFile threshold1 threshold2 threshold3 threshold4 " << std::endl; + std::cerr << " outputImageFile threshold1 threshold2 threshold3 threshold4 fullyConnected" << std::endl; return EXIT_FAILURE; } @@ -68,7 +68,11 @@ itkDoubleThresholdImageFilterTest(int argc, char * argv[]) auto rescaler = RescaleType::New(); // Create the filter - auto threshold = DoubleThresholdFilterType::New(); + auto threshold = DoubleThresholdFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(threshold, DoubleThresholdImageFilter, ImageToImageFilter); + + itk::SimpleFilterWatcher watcher(threshold, "threshold"); // Setup the input and output files @@ -129,7 +133,8 @@ itkDoubleThresholdImageFilterTest(int argc, char * argv[]) error = EXIT_FAILURE; } - threshold->SetFullyConnected(false); + auto fullyConnected = static_cast(std::stoi(argv[7])); + ITK_TEST_SET_GET_BOOLEAN(threshold, FullyConnected, fullyConnected); // Run the filter rescaler->SetInput(threshold->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx index 8dff92c08d2..2de986cc985 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx @@ -30,10 +30,11 @@ int itkGrayscaleGeodesicErodeDilateImageFilterTest(int argc, char * argv[]) { - if (argc < 4) + if (argc < 6) { std::cerr << "Missing arguments" << std::endl; - std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " Inputimage OutputImage Height" << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) + << " Inputimage OutputImage Height fullyConnected runOneIteration" << std::endl; return EXIT_FAILURE; } constexpr int Dimension = 2; @@ -52,9 +53,16 @@ itkGrayscaleGeodesicErodeDilateImageFilterTest(int argc, char * argv[]) auto writer = WriterType::New(); auto shiftErode = ShiftFilterType::New(); auto shiftDilate = ShiftFilterType::New(); + auto erode = ErodeFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(erode, GrayscaleGeodesicErodeImageFilter, ImageToImageFilter); + + auto dilate = DilateFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(dilate, GrayscaleGeodesicDilateImageFilter, ImageToImageFilter); + // Create the reader and writer reader->SetFileName(argv[1]); writer->SetFileName(argv[2]); @@ -66,7 +74,14 @@ itkGrayscaleGeodesicErodeDilateImageFilterTest(int argc, char * argv[]) // Dilate dilate->SetMarkerImage(shiftDilate->GetOutput()); dilate->SetMaskImage(reader->GetOutput()); - dilate->FullyConnectedOn(); + auto fullyConnected = static_cast(std::stoi(argv[4])); + + ITK_TEST_SET_GET_BOOLEAN(dilate, FullyConnected, fullyConnected); + + auto runOneIteration = static_cast(std::stoi(argv[5])); + + ITK_TEST_SET_GET_BOOLEAN(dilate, RunOneIteration, runOneIteration); + // Create the marker image for erode shiftErode->SetInput(dilate->GetOutput()); @@ -75,7 +90,10 @@ itkGrayscaleGeodesicErodeDilateImageFilterTest(int argc, char * argv[]) // Erode erode->SetMarkerImage(shiftErode->GetOutput()); erode->SetMaskImage(dilate->GetOutput()); - erode->FullyConnectedOn(); + + ITK_TEST_SET_GET_BOOLEAN(erode, FullyConnected, fullyConnected); + + ITK_TEST_SET_GET_BOOLEAN(erode, RunOneIteration, runOneIteration); writer->SetInput(erode->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx index 23e1bb5f953..34a735ecaa2 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx @@ -26,11 +26,11 @@ int itkGrayscaleMorphologicalClosingImageFilterTest(int argc, char * argv[]) { - if (argc < 3) + if (argc < 4) { std::cerr << "Missing arguments." << std::endl; std::cerr << "Usage: " << std::endl; - std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImage outputImage " << std::endl; + std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImage outputImage safeBorder" << std::endl; return EXIT_FAILURE; } @@ -68,6 +68,9 @@ itkGrayscaleMorphologicalClosingImageFilterTest(int argc, char * argv[]) itk::SimpleFilterWatcher watcher(filter, "filter"); + auto safeBorder = static_cast(std::stoi(argv[3])); + ITK_TEST_SET_GET_BOOLEAN(filter, SafeBorder, safeBorder); + // Connect the pipeline filter->SetInput(reader->GetOutput()); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx index daff94796a3..e4d994c9181 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx @@ -26,11 +26,11 @@ int itkGrayscaleMorphologicalOpeningImageFilterTest(int argc, char * argv[]) { - if (argc < 3) + if (argc < 4) { std::cerr << "Missing arguments." << std::endl; std::cerr << "Usage: " << std::endl; - std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImage outputImage " << std::endl; + std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImage outputImage safeBorder" << std::endl; return EXIT_FAILURE; } @@ -68,6 +68,9 @@ itkGrayscaleMorphologicalOpeningImageFilterTest(int argc, char * argv[]) itk::SimpleFilterWatcher watcher(filter, "filter"); + auto safeBorder = static_cast(std::stoi(argv[3])); + ITK_TEST_SET_GET_BOOLEAN(filter, SafeBorder, safeBorder); + // Connect the pipeline filter->SetInput(reader->GetOutput()); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx index cdaac0fdd77..54e1c4908a1 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx @@ -58,6 +58,11 @@ itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) MeshType::Pointer mesh = reader->GetOutput(); auto max_curvature = CurvatureFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + max_curvature, DiscreteMaximumCurvatureQuadEdgeMeshFilter, DiscretePrincipalCurvaturesQuadEdgeMeshFilter); + + max_curvature->SetInput(mesh); max_curvature->Update(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx index 38e9839b0ac..b8c6431f244 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx @@ -58,6 +58,11 @@ itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) MeshType::Pointer mesh = reader->GetOutput(); auto min_curvature = CurvatureFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + min_curvature, DiscreteMinimumCurvatureQuadEdgeMeshFilter, DiscretePrincipalCurvaturesQuadEdgeMeshFilter); + + min_curvature->SetInput(mesh); min_curvature->Update(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx index c19b51a85b7..e548a3caf85 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx @@ -20,6 +20,7 @@ #include "itkQuadEdgeMeshExtendedTraits.h" #include "itkNormalQuadEdgeMeshFilter.h" +#include "itkTestingMacros.h" int itkNormalQuadEdgeMeshFilterTest(int argc, char * argv[]) @@ -95,8 +96,14 @@ itkNormalQuadEdgeMeshFilterTest(int argc, char * argv[]) InputMeshType::Pointer mesh = reader->GetOutput(); auto normals = NormalFilterType::New(); - normals->SetInput(mesh); + ITK_EXERCISE_BASIC_OBJECT_METHODS(normals, NormalQuadEdgeMeshFilter, QuadEdgeMeshToQuadEdgeMeshFilter); + + normals->SetWeight(weight_type); + ITK_TEST_SET_GET_VALUE(weight_type, normals->GetWeight()); + + normals->SetInput(mesh); + normals->Update(); OutputMeshType::Pointer output = normals->GetOutput(); diff --git a/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx index 3e33d04251c..491db607b86 100644 --- a/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx @@ -89,8 +89,7 @@ itkIntermodesMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(maximumSmoothingIterations, filter->GetMaximumSmoothingIterations()); bool useInterMode = static_cast(std::stoi(argv[7])); - filter->SetUseInterMode(useInterMode); - ITK_TEST_SET_GET_VALUE(useInterMode, filter->GetUseInterMode()); + ITK_TEST_SET_GET_BOOLEAN(filter, UseInterMode, useInterMode); filter->SetInput(reader->GetOutput()); diff --git a/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx index 7bba34c6fdf..b1a4cfb0d0b 100644 --- a/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx @@ -104,8 +104,7 @@ itkIntermodesThresholdImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(maximumSmoothingIterations, filter->GetMaximumSmoothingIterations()); bool useInterMode = static_cast(std::stoi(argv[6])); - filter->SetUseInterMode(useInterMode); - ITK_TEST_SET_GET_VALUE(useInterMode, filter->GetUseInterMode()); + ITK_TEST_SET_GET_BOOLEAN(filter, UseInterMode, useInterMode); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/IO/MeshBase/test/itkMeshFileReaderWriterTest.cxx b/Modules/IO/MeshBase/test/itkMeshFileReaderWriterTest.cxx index afe9c6f317f..d44e064d9c4 100644 --- a/Modules/IO/MeshBase/test/itkMeshFileReaderWriterTest.cxx +++ b/Modules/IO/MeshBase/test/itkMeshFileReaderWriterTest.cxx @@ -57,12 +57,15 @@ itkMeshFileReaderWriterTest(int argc, char * argv[]) MeshType::Pointer readMesh = nullptr; ITK_TRY_EXPECT_NO_EXCEPTION(readMesh = itk::ReadMesh(inputFileName)); - const std::string outputFileName = argv[2]; - ITK_TRY_EXPECT_NO_EXCEPTION(itk::WriteMesh(readMesh.GetPointer(), outputFileName)); - ITK_TRY_EXPECT_NO_EXCEPTION(itk::WriteMesh(readMesh, outputFileName)); + std::string outputFileName = ""; + ITK_TRY_EXPECT_EXCEPTION(itk::WriteMesh(readMesh.GetPointer(), outputFileName)); + + const std::string constOutputFileName = argv[2]; + ITK_TRY_EXPECT_NO_EXCEPTION(itk::WriteMesh(readMesh.GetPointer(), constOutputFileName)); + ITK_TRY_EXPECT_NO_EXCEPTION(itk::WriteMesh(readMesh, constOutputFileName)); MeshType::Pointer writeReadMesh = nullptr; - ITK_TRY_EXPECT_NO_EXCEPTION(writeReadMesh = itk::ReadMesh(outputFileName)); + ITK_TRY_EXPECT_NO_EXCEPTION(writeReadMesh = itk::ReadMesh(constOutputFileName)); ITK_TEST_EXPECT_EQUAL(TestPointsContainer(readMesh->GetPoints(), writeReadMesh->GetPoints()), EXIT_SUCCESS); ITK_TEST_EXPECT_EQUAL(TestCellsContainer(readMesh->GetCells(), writeReadMesh->GetCells()), EXIT_SUCCESS); diff --git a/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx b/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx index c6ee2e3ace8..2a88f6c4b1e 100644 --- a/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx +++ b/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx @@ -60,7 +60,15 @@ itkMeshFileWriteReadTensorTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(mesh2dWriter, MeshFileWriter, ProcessObject); - mesh2dWriter->SetMeshIO(itk::VTKPolyDataMeshIO::New()); + itk::VTKPolyDataMeshIO::Pointer vtkPolyDataMeshIO = itk::VTKPolyDataMeshIO::New(); + + // Supported read extensions are empty by default + ITK_TEST_EXPECT_TRUE(vtkPolyDataMeshIO->GetSupportedReadExtensions().size() == 0); + + const itk::MeshIOBase::ArrayOfExtensionsType supportedExtensions{ ".vtk" }; + ITK_TEST_EXPECT_TRUE(vtkPolyDataMeshIO->GetSupportedWriteExtensions() == supportedExtensions); + + mesh2dWriter->SetMeshIO(vtkPolyDataMeshIO); mesh2dWriter->SetInput(mesh2d); mesh2dWriter->SetFileName(outputMesh2D); try diff --git a/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx b/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx index 7e02dd418f6..1161ada5b85 100644 --- a/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx +++ b/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx @@ -387,6 +387,9 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) auto writer = WriterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(writer, SpatialObjectWriter, Object); + + auto binaryPoints = false; if ((argc > 3) && (!strcmp(argv[2], "binary"))) @@ -399,8 +402,11 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) auto writeImagesInSeparateFile = false; ITK_TEST_SET_GET_BOOLEAN(writer, WriteImagesInSeparateFile, writeImagesInSeparateFile); + std::string fileName = argv[1]; + writer->SetFileName(fileName); + ITK_TEST_SET_GET_VALUE(fileName, writer->GetFileName()); + writer->SetInput(tubeN1); - writer->SetFileName(argv[1]); ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); @@ -410,14 +416,22 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) std::cout << "Testing Reading SceneSpatialObject: "; auto reader = ReaderType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(reader, SpatialObjectReader, Object); + + if ((argc > 2) && (strcmp(argv[2], "binary"))) { - reader->SetFileName(argv[2]); + fileName = argv[2]; } else { - reader->SetFileName(argv[1]); + fileName = argv[1]; } + + reader->SetFileName(fileName); + ITK_TEST_SET_GET_VALUE(fileName, reader->GetFileName()); + reader->Update(); ReaderType::SpatialObjectPointer myScene = reader->GetOutput(); diff --git a/Modules/Numerics/Optimizers/test/CMakeLists.txt b/Modules/Numerics/Optimizers/test/CMakeLists.txt index a7c7e4ee99f..5cd6757f8cc 100644 --- a/Modules/Numerics/Optimizers/test/CMakeLists.txt +++ b/Modules/Numerics/Optimizers/test/CMakeLists.txt @@ -55,6 +55,6 @@ itk_add_test(NAME itkAmoebaOptimizerTest itk_add_test(NAME itkParticleSwarmOptimizerTest COMMAND ITKOptimizersTestDriver itkParticleSwarmOptimizerTest) itk_add_test(NAME itkInitializationBiasedParticleSwarmOptimizerTest - COMMAND ITKOptimizersTestDriver itkInitializationBiasedParticleSwarmOptimizerTest) + COMMAND ITKOptimizersTestDriver itkInitializationBiasedParticleSwarmOptimizerTest 0.7298 1.49609 1.49609 1.49609) itk_add_test(NAME itkOnePlusOneEvolutionaryOptimizerTest COMMAND ITKOptimizersTestDriver itkOnePlusOneEvolutionaryOptimizerTest) diff --git a/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx index 07ec02b1d61..32ffbd0f120 100644 --- a/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx @@ -20,6 +20,7 @@ #include #include "itkInitializationBiasedParticleSwarmOptimizer.h" #include "itkParticleSwarmOptimizerTestFunctions.h" +#include "itkTestingMacros.h" using OptimizerType = itk::InitializationBiasedParticleSwarmOptimizer; static OptimizerType::RandomVariateGeneratorType::IntegerType seedOffset = 0; @@ -30,23 +31,29 @@ static OptimizerType::RandomVariateGeneratorType::IntegerType seedOffset = 0; * domain of either parabolas (runs the optimizer once with initial guess in * each of the domains). */ -int -IBPSOTest1(); +int IBPSOTest1(typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType); /** * Test using a 2D quadratic function (single minimum), check that converges * correctly. */ -int -IBPSOTest2(); +int IBPSOTest2(typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType); /** * Test using the 2D Rosenbrock function. */ -int -IBPSOTest3(); +int IBPSOTest3(typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType, + typename OptimizerType::CoefficientType); bool initalizationBasedTestVerboseFlag = false; @@ -58,9 +65,20 @@ bool initalizationBasedTestVerboseFlag = false; int itkInitializationBiasedParticleSwarmOptimizerTest(int argc, char * argv[]) { - if (argc > 1) + if (argc < 5) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inertiaCoefficient" + << " personalCoefficient" + << " globalCoefficient" + << " initializationCoefficient" + << " [initalizationBasedTestVerboseFlag]" << std::endl; + return EXIT_FAILURE; + } + + if (argc > 5) { - initalizationBasedTestVerboseFlag = std::stoi(argv[1]) ? true : false; + initalizationBasedTestVerboseFlag = std::stoi(argv[5]) ? true : false; } unsigned int i, allIterations = 10; @@ -69,18 +87,26 @@ itkInitializationBiasedParticleSwarmOptimizerTest(int argc, char * argv[]) std::cout << "Initialization Biased Particle Swarm Optimizer Test \n \n"; + auto inertiaCoefficient = static_cast(std::stod(argv[1])); + auto personalCoefficient = static_cast(std::stod(argv[2])); + auto globalCoefficient = static_cast(std::stod(argv[3])); + auto initializationCoefficient = static_cast(std::stod(argv[4])); + success1 = success2 = success3 = 0; for (i = 0; i < allIterations; ++i) { - if (EXIT_SUCCESS == IBPSOTest1()) + if (EXIT_SUCCESS == + IBPSOTest1(inertiaCoefficient, personalCoefficient, globalCoefficient, initializationCoefficient)) { success1++; } - if (EXIT_SUCCESS == IBPSOTest2()) + if (EXIT_SUCCESS == + IBPSOTest2(inertiaCoefficient, personalCoefficient, globalCoefficient, initializationCoefficient)) { success2++; } - if (EXIT_SUCCESS == IBPSOTest3()) + if (EXIT_SUCCESS == + IBPSOTest3(inertiaCoefficient, personalCoefficient, globalCoefficient, initializationCoefficient)) { success3++; } @@ -101,7 +127,10 @@ itkInitializationBiasedParticleSwarmOptimizerTest(int argc, char * argv[]) int -IBPSOTest1() +IBPSOTest1(typename OptimizerType::CoefficientType inertiaCoefficient, + typename OptimizerType::CoefficientType personalCoefficient, + typename OptimizerType::CoefficientType globalCoefficient, + typename OptimizerType::CoefficientType initializationCoefficient) { std::cout << "Particle Swarm Optimizer Test 1 [f(x) = if(x<0) x^2+4x; else 2x^2-8x]\n"; std::cout << "-------------------------------\n"; @@ -112,6 +141,23 @@ IBPSOTest1() itk::ParticleSwarmTestF1::Pointer costFunction = itk::ParticleSwarmTestF1::New(); auto itkOptimizer = OptimizerType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + itkOptimizer, InitializationBiasedParticleSwarmOptimizer, ParticleSwarmOptimizerBase); + + + itkOptimizer->SetInertiaCoefficient(inertiaCoefficient); + ITK_TEST_SET_GET_VALUE(inertiaCoefficient, itkOptimizer->GetInertiaCoefficient()); + + itkOptimizer->SetPersonalCoefficient(personalCoefficient); + ITK_TEST_SET_GET_VALUE(personalCoefficient, itkOptimizer->GetPersonalCoefficient()); + + itkOptimizer->SetGlobalCoefficient(globalCoefficient); + ITK_TEST_SET_GET_VALUE(globalCoefficient, itkOptimizer->GetGlobalCoefficient()); + + itkOptimizer->SetInitializationCoefficient(globalCoefficient); + ITK_TEST_SET_GET_VALUE(initializationCoefficient, itkOptimizer->GetInitializationCoefficient()); + itkOptimizer->UseSeedOn(); itkOptimizer->SetSeed(8775070 + seedOffset++); @@ -205,7 +251,10 @@ IBPSOTest1() int -IBPSOTest2() +IBPSOTest2(typename OptimizerType::CoefficientType inertiaCoefficient, + typename OptimizerType::CoefficientType personalCoefficient, + typename OptimizerType::CoefficientType globalCoefficient, + typename OptimizerType::CoefficientType initializationCoefficient) { std::cout << "Particle Swarm Optimizer Test 2 [f(x) = 1/2 x^T A x - b^T x]\n"; std::cout << "----------------------------------\n"; @@ -218,6 +267,23 @@ IBPSOTest2() itk::ParticleSwarmTestF2::Pointer costFunction = itk::ParticleSwarmTestF2::New(); auto itkOptimizer = OptimizerType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + itkOptimizer, InitializationBiasedParticleSwarmOptimizer, ParticleSwarmOptimizerBase); + + + itkOptimizer->SetInertiaCoefficient(inertiaCoefficient); + ITK_TEST_SET_GET_VALUE(inertiaCoefficient, itkOptimizer->GetInertiaCoefficient()); + + itkOptimizer->SetPersonalCoefficient(personalCoefficient); + ITK_TEST_SET_GET_VALUE(personalCoefficient, itkOptimizer->GetPersonalCoefficient()); + + itkOptimizer->SetGlobalCoefficient(globalCoefficient); + ITK_TEST_SET_GET_VALUE(globalCoefficient, itkOptimizer->GetGlobalCoefficient()); + + itkOptimizer->SetInitializationCoefficient(globalCoefficient); + ITK_TEST_SET_GET_VALUE(initializationCoefficient, itkOptimizer->GetInitializationCoefficient()); + itkOptimizer->UseSeedOn(); itkOptimizer->SetSeed(8775070 + seedOffset++); @@ -284,7 +350,10 @@ IBPSOTest2() } int -IBPSOTest3() +IBPSOTest3(typename OptimizerType::CoefficientType inertiaCoefficient, + typename OptimizerType::CoefficientType personalCoefficient, + typename OptimizerType::CoefficientType globalCoefficient, + typename OptimizerType::CoefficientType initializationCoefficient) { std::cout << "Particle Swarm Optimizer Test 3 [f(x,y) = (1-x)^2 + 100(y-x^2)^2]\n"; std::cout << "----------------------------------\n"; @@ -297,6 +366,23 @@ IBPSOTest3() itk::ParticleSwarmTestF3::Pointer costFunction = itk::ParticleSwarmTestF3::New(); auto itkOptimizer = OptimizerType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + itkOptimizer, InitializationBiasedParticleSwarmOptimizer, ParticleSwarmOptimizerBase); + + + itkOptimizer->SetInertiaCoefficient(inertiaCoefficient); + ITK_TEST_SET_GET_VALUE(inertiaCoefficient, itkOptimizer->GetInertiaCoefficient()); + + itkOptimizer->SetPersonalCoefficient(personalCoefficient); + ITK_TEST_SET_GET_VALUE(personalCoefficient, itkOptimizer->GetPersonalCoefficient()); + + itkOptimizer->SetGlobalCoefficient(globalCoefficient); + ITK_TEST_SET_GET_VALUE(globalCoefficient, itkOptimizer->GetGlobalCoefficient()); + + itkOptimizer->SetInitializationCoefficient(globalCoefficient); + ITK_TEST_SET_GET_VALUE(initializationCoefficient, itkOptimizer->GetInitializationCoefficient()); + itkOptimizer->UseSeedOn(); itkOptimizer->SetSeed(8775070 + seedOffset++); diff --git a/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx b/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx index 391c12a62dc..57f89632811 100644 --- a/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx +++ b/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx @@ -129,6 +129,9 @@ itkBlockMatchingImageFilterTest(int argc, char * argv[]) using BlockMatchingFilterType = itk::BlockMatchingImageFilter; auto blockMatchingFilter = BlockMatchingFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(blockMatchingFilter, BlockMatchingImageFilter, MeshToMeshFilter); + + // inputs (all required) blockMatchingFilter->SetFixedImage(resampleFilter->GetOutput()); blockMatchingFilter->SetMovingImage(reader->GetOutput()); @@ -136,7 +139,10 @@ itkBlockMatchingImageFilterTest(int argc, char * argv[]) // parameters (all optional) blockMatchingFilter->SetBlockRadius(blockRadius); + ITK_TEST_SET_GET_VALUE(blockRadius, blockMatchingFilter->GetBlockRadius()); + blockMatchingFilter->SetSearchRadius(searchRadius); + ITK_TEST_SET_GET_VALUE(searchRadius, blockMatchingFilter->GetSearchRadius()); std::cout << "Block matching: " << blockMatchingFilter << std::endl; try diff --git a/Modules/Registration/Common/test/itkPointSetToSpatialObjectDemonsRegistrationTest.cxx b/Modules/Registration/Common/test/itkPointSetToSpatialObjectDemonsRegistrationTest.cxx index 6989b15c144..cfcb16a38f1 100644 --- a/Modules/Registration/Common/test/itkPointSetToSpatialObjectDemonsRegistrationTest.cxx +++ b/Modules/Registration/Common/test/itkPointSetToSpatialObjectDemonsRegistrationTest.cxx @@ -20,6 +20,7 @@ #include "itkPointSetToSpatialObjectDemonsRegistration.h" #include "itkRegularSphereMeshSource.h" +#include "itkTestingMacros.h" int @@ -56,8 +57,14 @@ itkPointSetToSpatialObjectDemonsRegistrationTest(int, char *[]) auto demonsRegistration = DemonsRegistrationType::New(); - demonsRegistration->SetFixedPointSet(sphereSource->GetOutput()); + ITK_EXERCISE_BASIC_OBJECT_METHODS(demonsRegistration, PointSetToSpatialObjectDemonsRegistration, ProcessObject); + + auto fixedPointSet = sphereSource->GetOutput(); + demonsRegistration->SetFixedPointSet(fixedPointSet); + ITK_TEST_SET_GET_VALUE(fixedPointSet, demonsRegistration->GetFixedPointSet()); + demonsRegistration->SetMovingSpatialObject(ellipse); + ITK_TEST_SET_GET_VALUE(ellipse, demonsRegistration->GetMovingSpatialObject()); try diff --git a/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx b/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx index 864a921042c..fb4a448ae36 100644 --- a/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx @@ -18,6 +18,7 @@ #include "itkJensenHavrdaCharvatTsallisPointSetToPointSetMetricv4.h" #include "itkTranslationTransform.h" +#include "itkTestingMacros.h" #include @@ -90,6 +91,10 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun() float metricValues2D[] = { 0.143842f, -0.0129571f, -0.00105768f, -0.000115118f, -1.40956e-05f, -1.84099e-06f }; float metricValues3D[] = { 0.175588f, -0.0086854f, -0.000475248f, -3.46729e-05f, -2.84585e-06f, -2.49151e-07f }; + unsigned int evaluationKNeighborhood = 50; + auto useAnisotropicCovariances = false; + unsigned int covarianceKNeighborhood = 5; + for (unsigned int i = 0; i < numberOfAlphaValues; ++i) { @@ -98,10 +103,34 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun() // Instantiate the metric ( alpha = 1.0 ) using PointSetMetricType = itk::JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4; auto metric = PointSetMetricType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + metric, JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4, PointSetToPointSetMetricv4); + + + metric->SetAlpha(alphaValues[i]); + ITK_TEST_SET_GET_VALUE(alphaValues[i], metric->GetAlpha()); + + typename PointSetMetricType::RealType pointSetSigma = 1.0; + metric->SetPointSetSigma(pointSetSigma); + ITK_TEST_SET_GET_VALUE(pointSetSigma, metric->GetPointSetSigma()); + + metric->SetEvaluationKNeighborhood(evaluationKNeighborhood); + ITK_TEST_SET_GET_VALUE(evaluationKNeighborhood, metric->GetEvaluationKNeighborhood()); + + ITK_TEST_SET_GET_BOOLEAN(metric, UseAnisotropicCovariances, useAnisotropicCovariances); + + metric->SetCovarianceKNeighborhood(covarianceKNeighborhood); + ITK_TEST_SET_GET_VALUE(covarianceKNeighborhood, metric->GetCovarianceKNeighborhood()); + + typename PointSetMetricType::RealType kernelSigma = 10.0; + metric->SetKernelSigma(kernelSigma); + ITK_TEST_SET_GET_VALUE(kernelSigma, metric->GetKernelSigma()); + metric->SetFixedPointSet(fixedPoints); metric->SetMovingPointSet(movingPoints); metric->SetMovingTransform(translationTransform); - metric->SetAlpha(alphaValues[i]); + metric->Initialize(); typename PointSetMetricType::MeasureType value = metric->GetValue(), value2; diff --git a/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx index cebeb452aec..cd566d10a23 100644 --- a/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx @@ -196,6 +196,10 @@ itkDiffeomorphicDemonsRegistrationFilterTest(int argc, char * argv[]) auto registrator = RegistrationType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS( + registrator, DiffeomorphicDemonsRegistrationFilter, PDEDeformableRegistrationFilter); + + registrator->SetInitialDisplacementField(caster->GetOutput()); registrator->SetMovingImage(moving); @@ -237,16 +241,8 @@ itkDiffeomorphicDemonsRegistrationFilterTest(int argc, char * argv[]) std::cout << "GradientEnum = " << static_cast(registrator->GetUseGradientType()) << std::endl; - const int useFirstOrderExponential = std::stoi(argv[2]); - - if (useFirstOrderExponential == 0) - { - registrator->SetUseFirstOrderExp(false); - } - else - { - registrator->SetUseFirstOrderExp(true); - } + auto useFirstOrderExponential = static_cast(std::stoi(argv[2])); + ITK_TEST_SET_GET_BOOLEAN(registrator, UseFirstOrderExp, useFirstOrderExponential); // turn on inplace execution diff --git a/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx b/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx index 8e1547b1107..5d9669d5b5d 100644 --- a/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx @@ -233,13 +233,21 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) auto registrator = RegistrationType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(registrator, MultiResolutionPDEDeformableRegistration, ImageToImageFilter); + + registrator->SetMovingImage(moving); + ITK_TEST_SET_GET_VALUE(moving, registrator->GetMovingImage()); + registrator->SetFixedImage(fixed); + ITK_TEST_SET_GET_VALUE(fixed, registrator->GetFixedImage()); + registrator->GetModifiableFixedImagePyramid()->UseShrinkImageFilterOn(); registrator->GetModifiableMovingImagePyramid()->UseShrinkImageFilterOn(); - unsigned int numLevel = 3; - unsigned int numIterations[10]; + unsigned int numLevel = 3; + constexpr size_t arraySize = 10; + unsigned int numIterations[arraySize]; numIterations[0] = 64; unsigned int ilevel; @@ -249,9 +257,12 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) } registrator->SetNumberOfLevels(numLevel); - registrator->SetNumberOfIterations(numIterations); + ITK_TEST_SET_GET_VALUE(numLevel, registrator->GetNumberOfLevels()); - registrator->Print(std::cout); + registrator->SetNumberOfIterations(numIterations); + RegistrationType::NumberOfIterationsType numIterationsArr; + numIterationsArr.SetData(numIterations, numLevel); + ITK_TEST_SET_GET_VALUE(numIterationsArr, registrator->GetNumberOfIterations()); using CommandType = itk::SimpleMemberCommand; @@ -342,16 +353,6 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) return EXIT_FAILURE; } - // Exercise Get Methods - std::cout << "RegistrationFilter: " << registrator->GetRegistrationFilter() << std::endl; - std::cout << "FixedImage: " << registrator->GetFixedImage() << std::endl; - std::cout << "MovingImage: " << registrator->GetMovingImage() << std::endl; - std::cout << "FixedImagePyramid: " << registrator->GetFixedImagePyramid() << std::endl; - std::cout << "MovingImagePyramid: " << registrator->GetMovingImagePyramid() << std::endl; - std::cout << "NumberOfLevels: " << registrator->GetNumberOfLevels() << std::endl; - std::cout << "CurrentLevel: " << registrator->GetCurrentLevel() << std::endl; - std::cout << "NumberOfIterations[0]: " << registrator->GetNumberOfIterations()[0] << std::endl; - // Exercise error handling bool passed; @@ -371,6 +372,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) passed = true; registrator->ResetPipeline(); registrator->SetRegistrationFilter(demons); + ITK_TEST_SET_GET_VALUE(demons, registrator->GetRegistrationFilter()); } if (!passed) @@ -394,6 +396,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) passed = true; registrator->ResetPipeline(); registrator->SetFixedImagePyramid(fixedPyramid); + ITK_TEST_SET_GET_VALUE(fixedPyramid, registrator->GetFixedImagePyramid()); } if (!passed) @@ -418,6 +421,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) passed = true; registrator->ResetPipeline(); registrator->SetMovingImagePyramid(movingPyramid); + ITK_TEST_SET_GET_VALUE(movingPyramid, registrator->GetMovingImagePyramid()); } if (!passed) diff --git a/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx b/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx index 56ea7e75a98..d1538fd5172 100644 --- a/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx +++ b/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx @@ -43,6 +43,7 @@ TestBayesianClassifierImageFilterWithNoPriors(typename TInputImage::Pointer imag bayesianInitializer->SetInput(image); bayesianInitializer->SetNumberOfClasses(numberOfClasses); + ITK_TEST_SET_GET_VALUE(numberOfClasses, bayesianInitializer->GetNumberOfClasses()); auto bayesianClassifier = BayesianClassifierFilterType::New(); diff --git a/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx index 5f395e232b2..2d95781a058 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx @@ -114,7 +114,11 @@ itkScalarConnectedComponentImageFilterTest(int argc, char * argv[]) filter->SetInput(reader->GetOutput()); filter->SetMaskImage(mask); - filter->SetDistanceThreshold(std::stoi(argv[3])); + + auto distanceThreshold = static_cast(std::stod(argv[3])); + filter->SetDistanceThreshold(distanceThreshold); + ITK_TEST_SET_GET_VALUE(distanceThreshold, filter->GetDistanceThreshold()); + filter->SetFunctor(filter->GetFunctor()); if (argc > 4) diff --git a/Modules/Segmentation/DeformableMesh/test/CMakeLists.txt b/Modules/Segmentation/DeformableMesh/test/CMakeLists.txt index 94600d33f29..2283b55dc45 100644 --- a/Modules/Segmentation/DeformableMesh/test/CMakeLists.txt +++ b/Modules/Segmentation/DeformableMesh/test/CMakeLists.txt @@ -11,7 +11,7 @@ CreateTestDriver(ITKDeformableMesh "${ITKDeformableMesh-Test_LIBRARIES}" "${ITK itk_add_test(NAME itkDeformableSimplexMesh3DFilterTest COMMAND ITKDeformableMeshTestDriver itkDeformableSimplexMesh3DFilterTest) itk_add_test(NAME itkDeformableSimplexMesh3DBalloonForceFilterTest - COMMAND ITKDeformableMeshTestDriver itkDeformableSimplexMesh3DBalloonForceFilterTest) + COMMAND ITKDeformableMeshTestDriver itkDeformableSimplexMesh3DBalloonForceFilterTest 0.01) itk_add_test(NAME itkDeformableSimplexMesh3DGradientConstaintForceFilterTest COMMAND ITKDeformableMeshTestDriver itkDeformableSimplexMesh3DGradientConstraintForceFilterTest) itk_add_test(NAME itkSimplexMeshWithFloatCoordRepTest diff --git a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx index 8df0b43aba7..4cb72090da8 100644 --- a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx +++ b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx @@ -25,10 +25,18 @@ #include "itkSobelEdgeDetectionImageFilter.h" #include "itkGradientRecursiveGaussianImageFilter.h" +#include "itkTestingMacros.h" int -itkDeformableSimplexMesh3DBalloonForceFilterTest(int, char *[]) +itkDeformableSimplexMesh3DBalloonForceFilterTest(int argc, char * argv[]) { + if (argc != 2) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << std::endl; + std::cerr << itkNameOfTestExecutableMacro(argv) << " kappa" << std::endl; + return EXIT_FAILURE; + } // Declare the type of the input and output mesh using TriangleMeshTraits = itk::DefaultDynamicMeshTraits; @@ -116,11 +124,20 @@ itkDeformableSimplexMesh3DBalloonForceFilterTest(int, char *[]) std::cout << "done." << std::endl; auto deformFilter = DeformFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + deformFilter, DeformableSimplexMesh3DBalloonForceFilter, DeformableSimplexMesh3DFilter); + + deformFilter->SetInput(simplexFilter->GetOutput()); deformFilter->SetGradient(gradientFilter->GetOutput()); deformFilter->SetAlpha(0.2); deformFilter->SetBeta(0.1); - deformFilter->SetKappa(0.01); + + auto kappa = std::stod(argv[1]); + deformFilter->SetKappa(kappa); + ITK_TEST_SET_GET_VALUE(kappa, deformFilter->GetKappa()); + deformFilter->SetIterations(100); deformFilter->SetRigidity(0); deformFilter->Update(); diff --git a/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx b/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx index d5884616e87..7dde36a08cf 100644 --- a/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx +++ b/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx @@ -20,6 +20,7 @@ #include "itkBinaryThresholdImageFilter.h" #include "itkBinaryMedianImageFilter.h" #include "itkTextOutput.h" +#include "itkTestingMacros.h" int itkBinaryMedianImageFilterTest(int, char *[]) @@ -59,9 +60,16 @@ itkBinaryMedianImageFilterTest(int, char *[]) // Create a median image itk::BinaryMedianImageFilter::Pointer median; median = itk::BinaryMedianImageFilter::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(median, BinaryMedianImageFilter, ImageToImageFilter); + + median->SetInput(thresholder->GetOutput()); median->SetForegroundValue(foreground); + ITK_TEST_SET_GET_VALUE(foreground, median->GetForegroundValue()); + median->SetBackgroundValue(background); + ITK_TEST_SET_GET_VALUE(background, median->GetBackgroundValue()); // define the neighborhood size used for the median filter (5x5) @@ -69,6 +77,7 @@ itkBinaryMedianImageFilterTest(int, char *[]) neighRadius[0] = 1; neighRadius[1] = 1; median->SetRadius(neighRadius); + ITK_TEST_SET_GET_VALUE(neighRadius, median->GetRadius()); // run the algorithm median->Update(); diff --git a/Modules/Segmentation/LevelSets/test/CMakeLists.txt b/Modules/Segmentation/LevelSets/test/CMakeLists.txt index 28ada0042c3..084ea369436 100644 --- a/Modules/Segmentation/LevelSets/test/CMakeLists.txt +++ b/Modules/Segmentation/LevelSets/test/CMakeLists.txt @@ -67,7 +67,7 @@ itk_add_test(NAME itkNarrowBandCurvesLevelSetImageFilterTest1 ${ITK_TEST_OUTPUT_DIR}/itkNarrowBandCurvesLevelSetImageFilterTest.png itkNarrowBandCurvesLevelSetImageFilterTest ${ITK_TEST_OUTPUT_DIR}/itkNarrowBandCurvesLevelSetImageFilterTest.png) itk_add_test(NAME itkCollidingFrontsImageFilterTest - COMMAND ITKLevelSetsTestDriver itkCollidingFrontsImageFilterTest) + COMMAND ITKLevelSetsTestDriver itkCollidingFrontsImageFilterTest 1 1) itk_add_test(NAME itkGeodesicActiveContourShapePriorLevelSetImageFilterTest COMMAND ITKLevelSetsTestDriver itkGeodesicActiveContourShapePriorLevelSetImageFilterTest) itk_add_test(NAME itkLevelSetFunctionTest @@ -97,4 +97,4 @@ itk_add_test(NAME itkCurvesLevelSetImageFilterTest itk_add_test(NAME itkCurvesLevelSetImageFilterZeroSigmaTest COMMAND ITKLevelSetsTestDriver itkCurvesLevelSetImageFilterZeroSigmaTest) itk_add_test(NAME itkBinaryMaskToNarrowBandPointSetFilterTest - COMMAND ITKLevelSetsTestDriver itkBinaryMaskToNarrowBandPointSetFilterTest) + COMMAND ITKLevelSetsTestDriver itkBinaryMaskToNarrowBandPointSetFilterTest 5.0) diff --git a/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx index 8b4193825b7..75080079414 100644 --- a/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx @@ -19,10 +19,19 @@ #include "itkBinaryMaskToNarrowBandPointSetFilter.h" #include "itkPointSet.h" #include "itkImageRegionIterator.h" +#include "itkTestingMacros.h" int -itkBinaryMaskToNarrowBandPointSetFilterTest(int, char *[]) +itkBinaryMaskToNarrowBandPointSetFilterTest(int argc, char * argv[]) { + if (argc != 2) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << std::endl; + std::cerr << itkNameOfTestExecutableMacro(argv) << " bandWidth" << std::endl; + return EXIT_FAILURE; + } + constexpr unsigned int Dimension = 2; using BinaryMaskPixelType = unsigned char; @@ -78,6 +87,13 @@ itkBinaryMaskToNarrowBandPointSetFilterTest(int, char *[]) auto narrowBandGenerator = GeneratorType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(narrowBandGenerator, BinaryMaskToNarrowBandPointSetFilter, ImageToMeshFilter); + + + auto bandWidth = std::stod(argv[1]); + narrowBandGenerator->SetBandWidth(bandWidth); + ITK_TEST_SET_GET_VALUE(bandWidth, narrowBandGenerator->GetBandWidth()); + narrowBandGenerator->SetInput(binaryMask); try diff --git a/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx index 05e971aba84..30c7d3ee901 100644 --- a/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx @@ -21,10 +21,18 @@ #include "itkCastImageFilter.h" #include "itkRescaleIntensityImageFilter.h" #include "itkImageFileWriter.h" +#include "itkTestingMacros.h" int itkCollidingFrontsImageFilterTest(int argc, char * argv[]) { + if (argc < 3) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) + << " applyConnectivity stopOnTargets [inputFilename] [outputFilename]" << std::endl; + return EXIT_FAILURE; + } constexpr unsigned int ImageDimension = 2; using PixelType = unsigned char; @@ -56,8 +64,10 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) using CollidingFrontsFilterType = itk::CollidingFrontsImageFilter; auto collidingFronts = CollidingFrontsFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(collidingFronts, CollidingFrontsImageFilter, ImageToImageFilter); + using NodeContainer = CollidingFrontsFilterType::NodeContainer; - using NodeType = CollidingFrontsFilterType::NodeType; + using NodeType = typename CollidingFrontsFilterType::NodeType; // select seeds 20 pixels apart @@ -93,7 +103,10 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) collidingFronts->SetInput(caster->GetOutput()); collidingFronts->SetSeedPoints1(seeds1); collidingFronts->SetSeedPoints2(seeds2); - collidingFronts->ApplyConnectivityOn(); + + auto applyConnectivity = static_cast(std::stoi(argv[1])); + ITK_TEST_SET_GET_BOOLEAN(collidingFronts, ApplyConnectivity, applyConnectivity); + try { collidingFronts->Update(); @@ -145,7 +158,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) } // Optionally writing out the two images - if (argc > 2) + if (argc > 3) { using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); @@ -153,7 +166,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) using RescaleFilterType = itk::RescaleIntensityImageFilter; auto rescaler = RescaleFilterType::New(); - writer->SetFileName(argv[1]); + writer->SetFileName(argv[3]); writer->SetInput(inputImage); writer->Update(); @@ -161,7 +174,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) rescaler->SetOutputMinimum(0); rescaler->SetOutputMaximum(255); - writer->SetFileName(argv[2]); + writer->SetFileName(argv[4]); writer->SetInput(rescaler->GetOutput()); writer->Update(); } @@ -172,7 +185,9 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - collidingFronts->StopOnTargetsOn(); + auto stopOnTargets = static_cast(std::stoi(argv[2])); + ITK_TEST_SET_GET_BOOLEAN(collidingFronts, StopOnTargets, stopOnTargets); + try { collidingFronts->Update(); diff --git a/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx index ccdcdb2ea38..b11a95c5464 100644 --- a/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx @@ -17,6 +17,7 @@ *=========================================================================*/ #include "itkNarrowBandThresholdSegmentationLevelSetImageFilter.h" +#include "itkTestingMacros.h" namespace NBTS { @@ -147,6 +148,11 @@ itkNarrowBandThresholdSegmentationLevelSetImageFilterTest(int, char *[]) itk::NarrowBandThresholdSegmentationLevelSetImageFilter<::NBTS::SeedImageType, ::NBTS::ImageType>::Pointer filter = itk::NarrowBandThresholdSegmentationLevelSetImageFilter<::NBTS::SeedImageType, ::NBTS::ImageType>::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS( + filter, NarrowBandThresholdSegmentationLevelSetImageFilter, NarrowBandLevelSetImageFilter); + + filter->SetInput(seedImage); filter->SetFeatureImage(inputImage); filter->SetNumberOfWorkUnits(2); diff --git a/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx index c3fa329d0c6..1824f6ead37 100644 --- a/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx @@ -24,6 +24,7 @@ #include "itkFastMarchingImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkSimilarityIndexImageFilter.h" +#include "itkTestingMacros.h" /* Uncomment to write out image files */ /* @@ -136,6 +137,10 @@ itkShapeDetectionLevelSetImageFilterTest(int, char *[]) auto shapeDetection = ShapeDetectionFilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS( + shapeDetection, ShapeDetectionLevelSetImageFilter, SegmentationLevelSetImageFilter); + + // set the initial level set shapeDetection->SetInput(fastMarching->GetOutput()); diff --git a/Modules/Segmentation/LevelSets/test/itkVectorThresholdSegmentationLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkVectorThresholdSegmentationLevelSetImageFilterTest.cxx index a965bab0fb4..d4be6ba3bbb 100644 --- a/Modules/Segmentation/LevelSets/test/itkVectorThresholdSegmentationLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkVectorThresholdSegmentationLevelSetImageFilterTest.cxx @@ -64,6 +64,10 @@ itkVectorThresholdSegmentationLevelSetImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS( + filter, VectorThresholdSegmentationLevelSetImageFilter, SegmentationLevelSetImageFilter); + + filter->SetInput(inputReader->GetOutput()); filter->SetFeatureImage(rgbReader->GetOutput()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx index d34398bf750..cd208618a9c 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx @@ -17,6 +17,7 @@ *=========================================================================*/ #include "itkLevelSetDomainMapImageFilter.h" +#include "itkTestingMacros.h" int itkLevelSetDomainMapImageFilterTest(int, char *[]) @@ -61,6 +62,10 @@ itkLevelSetDomainMapImageFilterTest(int, char *[]) } auto filter = DomainMapImageFilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, LevelSetDomainMapImageFilter, ImageToImageFilter); + + filter->SetInput(input); filter->Update(); diff --git a/Modules/Segmentation/Voronoi/test/CMakeLists.txt b/Modules/Segmentation/Voronoi/test/CMakeLists.txt index 5516319e440..b8de9ca6884 100644 --- a/Modules/Segmentation/Voronoi/test/CMakeLists.txt +++ b/Modules/Segmentation/Voronoi/test/CMakeLists.txt @@ -9,7 +9,7 @@ itkVoronoiPartitioningImageFilterTest.cxx CreateTestDriver(ITKVoronoi "${ITKVoronoi-Test_LIBRARIES}" "${ITKVoronoiTests}") itk_add_test(NAME itkVoronoiSegmentationImageFilterTest - COMMAND ITKVoronoiTestDriver itkVoronoiSegmentationImageFilterTest) + COMMAND ITKVoronoiTestDriver itkVoronoiSegmentationImageFilterTest 520.0 20.0 10.0 20.0 400 5 0.1 1.5) itk_add_test(NAME itkVoronoiSegmentationRGBImageFilterTest COMMAND ITKVoronoiTestDriver itkVoronoiSegmentationRGBImageFilterTest) itk_add_test(NAME itkVoronoiDiagram2DTest diff --git a/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx b/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx index 9274db1cede..3ee3c16a6d4 100644 --- a/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx +++ b/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx @@ -21,8 +21,17 @@ #include "itkTestingMacros.h" int -itkVoronoiSegmentationImageFilterTest(int, char *[]) +itkVoronoiSegmentationImageFilterTest(int argc, char * argv[]) { + if (argc != 9) + { + std::cerr << "Missing Parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) + << " mean std meanTolerance stdTolerance numberOfSeeds steps meanPercentError stdPercentError" + << std::endl; + return EXIT_FAILURE; + } + constexpr int width = 256; constexpr int height = 256; @@ -91,27 +100,38 @@ itkVoronoiSegmentationImageFilterTest(int, char *[]) voronoiSegmenter->SetInput(inputImage); - double mean = 520; - double std = 20; - double meanTolerance = 10; - double stdTolerance = 20; - int numberOfSeeds = 400; - int steps = 5; - + auto mean = std::stod(argv[1]); voronoiSegmenter->SetMean(mean); - voronoiSegmenter->SetSTD(std); - voronoiSegmenter->SetMeanTolerance(meanTolerance); - voronoiSegmenter->SetSTDTolerance(stdTolerance); - voronoiSegmenter->SetNumberOfSeeds(numberOfSeeds); - voronoiSegmenter->SetSteps(steps); - ITK_TEST_SET_GET_VALUE(mean, voronoiSegmenter->GetMean()); + + auto std = std::stod(argv[2]); + voronoiSegmenter->SetSTD(std); ITK_TEST_SET_GET_VALUE(std, voronoiSegmenter->GetSTD()); + + auto meanTolerance = std::stod(argv[3]); + voronoiSegmenter->SetMeanTolerance(meanTolerance); ITK_TEST_SET_GET_VALUE(meanTolerance, voronoiSegmenter->GetMeanTolerance()); + + auto stdTolerance = std::stod(argv[4]); + voronoiSegmenter->SetSTDTolerance(stdTolerance); ITK_TEST_SET_GET_VALUE(stdTolerance, voronoiSegmenter->GetSTDTolerance()); + + auto numberOfSeeds = std::stoi(argv[5]); + voronoiSegmenter->SetNumberOfSeeds(numberOfSeeds); ITK_TEST_SET_GET_VALUE(numberOfSeeds, voronoiSegmenter->GetNumberOfSeeds()); + + auto steps = std::stoi(argv[6]); + voronoiSegmenter->SetSteps(steps); ITK_TEST_SET_GET_VALUE(steps, voronoiSegmenter->GetSteps()); + auto meanPercentError = std::stod(argv[7]); + voronoiSegmenter->SetMeanPercentError(meanPercentError); + ITK_TEST_SET_GET_VALUE(meanPercentError, voronoiSegmenter->GetMeanPercentError()); + + auto stdPercentError = std::stod(argv[8]); + voronoiSegmenter->SetSTDPercentError(stdPercentError); + ITK_TEST_SET_GET_VALUE(stdPercentError, voronoiSegmenter->GetSTDPercentError()); + std::cout << "Running algorithm" << std::endl; voronoiSegmenter->Update(); diff --git a/Modules/Video/Filtering/test/itkDecimateFramesVideoFilterTest.cxx b/Modules/Video/Filtering/test/itkDecimateFramesVideoFilterTest.cxx index b2aced92922..d8d759ce6b3 100644 --- a/Modules/Video/Filtering/test/itkDecimateFramesVideoFilterTest.cxx +++ b/Modules/Video/Filtering/test/itkDecimateFramesVideoFilterTest.cxx @@ -93,6 +93,9 @@ itkDecimateFramesVideoFilterTest(int argc, char * argv[]) auto writer = WriterType::New(); auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, DecimateFramesVideoFilter, VideoToVideoFilter); + + // Connect the pipeline filter->SetInput(reader->GetOutput()); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx b/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx index 6403d5aa126..e04dc8654e1 100644 --- a/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx +++ b/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx @@ -99,6 +99,9 @@ itkFrameAverageVideoFilterTest(int argc, char * argv[]) using FilterType = itk::FrameAverageVideoFilter; auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, FrameAverageVideoFilter, VideoToVideoFilter); + + // Set up an input VideoStream auto inputVideo = InputVideoType::New(); SizeValueType numInputFrames = 50; diff --git a/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx b/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx index 2df6f004dc9..28779555a50 100644 --- a/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx +++ b/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx @@ -21,6 +21,7 @@ #include "itkVideoFileReader.h" #include "itkVideoFileWriter.h" #include "itkFileListVideoIOFactory.h" +#include "itkTestingMacros.h" // Set up type alias for test @@ -87,6 +88,8 @@ itkFrameDifferenceVideoFilterTest(int itkNotUsed(argc), char * itkNotUsed(argv)[ using FilterType = itk::FrameDifferenceVideoFilter; auto filter = FilterType::New(); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, FrameDifferenceVideoFilter, VideoToVideoFilter); + // Set up an input VideoStream auto inputVideo = InputVideoType::New();