Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 6 additions & 42 deletions Modules/Filtering/ImageIntensity/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
itk_module_test()
set(
ITKImageIntensityTests
itkAbsImageFilterAndAdaptorTest.cxx
itkAcosImageFilterAndAdaptorTest.cxx
itkAdaptImageFilterTest.cxx
itkAdaptImageFilterTest2.cxx
itkAddImageAdaptorTest.cxx
itkAddImageFilterFrameTest.cxx
itkAddImageFilterTest.cxx
itkAddImageFilterTest2.cxx
itkAndImageFilterTest.cxx
Expand Down Expand Up @@ -255,12 +249,6 @@ itk_add_test(
ITKImageIntensityTestDriver
itkComplexToModulusFilterAndAdaptorTest
)
itk_add_test(
NAME itkAddImageAdaptorTest
COMMAND
ITKImageIntensityTestDriver
itkAddImageAdaptorTest
)
itk_add_test(
NAME itkAndImageFilterTest
COMMAND
Expand All @@ -271,12 +259,6 @@ itk_add_test(
itkAndImageFilterTest
${ITK_TEST_OUTPUT_DIR}/itkAndImageFilterTest.png
)
itk_add_test(
NAME itkAdaptImageFilterTest2
COMMAND
ITKImageIntensityTestDriver
itkAdaptImageFilterTest2
)
itk_add_test(
NAME itkLogImageFilterAndAdaptorTest
COMMAND
Expand Down Expand Up @@ -331,12 +313,6 @@ itk_add_test(
DATA{${ITK_DATA_ROOT}/Input/HeadMRVolume.mha}
${TEMP}/itkAddImageFilterTest2.mha
)
itk_add_test(
NAME itkAddImageFilterFrameTest
COMMAND
ITKImageIntensityTestDriver
itkAddImageFilterFrameTest
)
itk_add_test(
NAME itkPowImageFilterTest
COMMAND
Expand Down Expand Up @@ -412,12 +388,6 @@ itk_add_test(
itkTernaryMagnitudeImageFilterTest
${ITK_TEST_OUTPUT_DIR}/itkTernaryMagnitudeImageFilterTest.png
)
itk_add_test(
NAME itkAbsImageFilterAndAdaptorTest
COMMAND
ITKImageIntensityTestDriver
itkAbsImageFilterAndAdaptorTest
)
itk_add_test(
NAME itkMaximumImageFilterTest
COMMAND
Expand Down Expand Up @@ -494,12 +464,6 @@ itk_add_test(
ITKImageIntensityTestDriver
itkHistogramMatchingImageFilterTest
)
itk_add_test(
NAME itkAcosImageFilterAndAdaptorTest
COMMAND
ITKImageIntensityTestDriver
itkAcosImageFilterAndAdaptorTest
)
itk_add_test(
NAME itkExpNegativeImageFilterAndAdaptorTest
COMMAND
Expand Down Expand Up @@ -550,12 +514,6 @@ if(NOT ITK_LEGACY_REMOVE)
itkVectorExpandImageFilterTest
)
endif()
itk_add_test(
NAME itkAdaptImageFilterTest
COMMAND
ITKImageIntensityTestDriver
itkAdaptImageFilterTest
)
itk_add_test(
NAME itkOrImageFilterTest
COMMAND
Expand Down Expand Up @@ -821,6 +779,12 @@ itk_add_test(

set(
ITKImageIntensityGTests
itkAbsImageFilterAndAdaptorGTest.cxx
itkAcosImageFilterAndAdaptorGTest.cxx
itkAdaptImageFilterGTest.cxx
itkAdaptImageFilterGTest2.cxx
itkAddImageAdaptorGTest.cxx
itkAddImageFilterFrameGTest.cxx
itkArithmeticOpsFunctorsTest.cxx
itkBitwiseOpsFunctorsTest.cxx
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
#include "itkMath.h"
#include "itkSubtractImageFilter.h"
#include "itkUnaryGeneratorImageFilter.h"
#include "itkTestingMacros.h"
#include "itkGTest.h"

int
itkAbsImageFilterAndAdaptorTest(int, char *[])
TEST(AbsImageFilterAndAdaptor, ConvertedLegacyTest)
{
int testStatus = EXIT_SUCCESS;

// Define the dimension of the images
constexpr unsigned int ImageDimension{ 3 };

Expand Down Expand Up @@ -63,12 +60,10 @@ itkAbsImageFilterAndAdaptorTest(int, char *[])
// Initialize the content of Image A
const double pi = std::atan(1.0) * 4.0;
const double value = pi / 6.0;
std::cout << "Content of the Input " << std::endl;
it.GoToBegin();
while (!it.IsAtEnd())
{
it.Set(value);
std::cout << it.Get() << std::endl;
++it;
}

Expand All @@ -78,7 +73,7 @@ itkAbsImageFilterAndAdaptorTest(int, char *[])
// Create an Abs Filter
auto filter = FilterType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, AbsImageFilter, UnaryGeneratorImageFilter);
ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(filter, AbsImageFilter, UnaryGeneratorImageFilter);

// Connect the input images
filter->SetInput(inputImage);
Expand All @@ -93,27 +88,15 @@ itkAbsImageFilterAndAdaptorTest(int, char *[])
OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion());

// Check the content of the result image
std::cout << "Verification of the output " << std::endl;
constexpr OutputImageType::PixelType epsilon{ 1e-6 };
ot.GoToBegin();
it.GoToBegin();
while (!ot.IsAtEnd())
{
std::cout.precision(static_cast<int>(itk::Math::Absolute(std::log10(epsilon))));
std::cout << ot.Get() << " = ";
std::cout << itk::Math::Absolute(it.Get()) << std::endl;
const InputImageType::PixelType input = it.Get();
const OutputImageType::PixelType output = ot.Get();
const OutputImageType::PixelType absolute = itk::Math::Absolute(input);
if (!itk::Math::FloatAlmostEqual(absolute, output, 10, epsilon))
{
std::cerr.precision(static_cast<int>(itk::Math::Absolute(std::log10(epsilon))));
std::cerr << "Error in itkAbsImageFilterTest " << std::endl;
std::cerr << " itk::Math::Absolute(" << input << ") = " << absolute << std::endl;
std::cerr << " differs from " << output;
std::cerr << " by more than " << epsilon << std::endl;
testStatus = EXIT_FAILURE;
}
EXPECT_NEAR(absolute, output, epsilon);
++ot;
++it;
}
Expand All @@ -126,7 +109,7 @@ itkAbsImageFilterAndAdaptorTest(int, char *[])

auto absAdaptor = AdaptorType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(absAdaptor, AbsImageAdaptor, ImageAdaptor);
ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(absAdaptor, AbsImageAdaptor, ImageAdaptor);

absAdaptor->SetImage(inputImage);

Expand All @@ -143,30 +126,14 @@ itkAbsImageFilterAndAdaptorTest(int, char *[])
const OutputImageType::Pointer diffImage = diffFilter->GetOutput();

// Check the content of the diff image
std::cout << "Comparing the results with those of an Adaptor" << std::endl;
std::cout << "Verification of the output " << std::endl;

// Create an iterator for going through the image output
OutputIteratorType dt(diffImage, diffImage->GetRequestedRegion());

dt.GoToBegin();
while (!dt.IsAtEnd())
{
std::cout.precision(static_cast<int>(itk::Math::Absolute(std::log10(epsilon))));
std::cout << dt.Get() << std::endl;
const OutputImageType::PixelType diff = dt.Get();
if (!itk::Math::FloatAlmostEqual(diff, OutputImageType::PixelType{ 0 }, 10, epsilon))
{
std::cerr.precision(static_cast<int>(itk::Math::Absolute(std::log10(epsilon))));
std::cerr << "Error in itkAbsImageFilterTest " << std::endl;
std::cerr << "Comparing results with Adaptors" << std::endl;
std::cerr << " difference = " << diff << std::endl;
std::cerr << " differs from 0 ";
std::cerr << " by more than " << epsilon << std::endl;
testStatus = EXIT_FAILURE;
}
EXPECT_NEAR(diff, OutputImageType::PixelType{ 0 }, epsilon);
++dt;
}

return testStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
#include "itkMath.h"
#include "itkSubtractImageFilter.h"
#include "itkSimpleFilterWatcher.h"
#include "itkTestingMacros.h"
#include "itkGTest.h"


int
itkAcosImageFilterAndAdaptorTest(int, char *[])
TEST(AcosImageFilterAndAdaptor, ConvertedLegacyTest)
{

// Define the dimension of the images
constexpr unsigned int ImageDimension{ 3 };

Expand Down Expand Up @@ -75,7 +73,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[])
// Create the Filter
auto filter = FilterType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, AcosImageFilter, UnaryGeneratorImageFilter);
ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(filter, AcosImageFilter, UnaryGeneratorImageFilter);

const itk::SimpleFilterWatcher watch(filter);

Expand All @@ -101,15 +99,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[])
const InputImageType::PixelType input = it.Get();
const OutputImageType::PixelType output = ot.Get();
const OutputImageType::PixelType arccosinus = std::acos(input);
if (!itk::Math::FloatAlmostEqual(arccosinus, output, 10, epsilon))
{
std::cerr.precision(static_cast<int>(itk::Math::Absolute(std::log10(epsilon))));
std::cerr << "Error " << std::endl;
std::cerr << " std::acos( " << input << ") = " << arccosinus << std::endl;
std::cerr << " differs from " << output;
std::cerr << " by more than " << epsilon << std::endl;
return EXIT_FAILURE;
}
EXPECT_NEAR(arccosinus, output, epsilon);
++ot;
++it;
}
Expand All @@ -123,7 +113,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[])

auto acosAdaptor = AdaptorType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(acosAdaptor, AcosImageAdaptor, ImageAdaptor);
ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(acosAdaptor, AcosImageAdaptor, ImageAdaptor);

acosAdaptor->SetImage(inputImage);

Expand All @@ -149,17 +139,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[])
while (!dt.IsAtEnd())
{
const OutputImageType::PixelType diff = dt.Get();
if (itk::Math::Absolute(diff) > epsilon)
{
std::cerr.precision(static_cast<int>(itk::Math::Absolute(std::log10(epsilon))));
std::cerr << "Error comparing results with Adaptors" << std::endl;
std::cerr << " difference = " << diff << std::endl;
std::cerr << " differs from 0 ";
std::cerr << " by more than " << epsilon << std::endl;
return EXIT_FAILURE;
}
EXPECT_LE(itk::Math::Absolute(diff), epsilon);
++dt;
}

return EXIT_SUCCESS;
}
Loading
Loading