25 CPPUNIT_TEST_SUITE(mitkImageEqualTestSuite);
26 MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue);
27 MITK_TEST(Equal_DifferentImageGeometry_ReturnsFalse);
28 MITK_TEST(Equal_DifferentPixelTypes_ReturnsFalse);
29 MITK_TEST(Equal_DifferentDimensions_ReturnsFalse);
30 MITK_TEST(Equal_DifferentDimensionalities_ReturnsFalse);
31 MITK_TEST(Equal_DifferentPixelValues_ReturnsFalse);
32 CPPUNIT_TEST_SUITE_END();
47 m_Image = mitk::ImageGenerator::GenerateGradientImage<unsigned char>(3u, 3u, 1u);
48 m_AnotherImage = m_Image->Clone();
51 void tearDown()
override
54 m_AnotherImage =
nullptr;
57 void Equal_CloneAndOriginal_ReturnsTrue()
59 MITK_ASSERT_EQUAL(m_Image, m_Image->Clone(),
"A clone should be equal to its original.");
62 void Equal_DifferentImageGeometry_ReturnsFalse()
69 m_AnotherImage->GetGeometry()->SetOrigin(origin);
74 void Equal_DifferentPixelTypes_ReturnsFalse()
76 m_AnotherImage = mitk::ImageGenerator::GenerateGradientImage<float>(3u, 3u, 1u);
79 m_Image, m_AnotherImage,
"One pixel type is float, the other unsigned char. Result should be false.");
82 void Equal_DifferentDimensions_ReturnsFalse()
84 m_AnotherImage = mitk::ImageGenerator::GenerateGradientImage<unsigned char>(5u, 7u, 3u);
89 "Dimensions of first image are: (3, 3, 1). Dimensions of second image are: (5, 7, 3). Result should be false.");
92 void Equal_DifferentDimensionalities_ReturnsFalse()
96 sliceSelector->SetInput(m_Image);
97 sliceSelector->SetSliceNr(0);
98 sliceSelector->Update();
99 m_AnotherImage = sliceSelector->GetOutput();
101 MITK_ASSERT_NOT_EQUAL(m_Image, m_AnotherImage,
"First image is 3D. Second image is 2D. Result should be false.");
104 void Equal_DifferentPixelValues_ReturnsFalse()
107 m_Image = mitk::ImageGenerator::GenerateRandomImage<unsigned char>(3u, 3u);
108 m_AnotherImage = mitk::ImageGenerator::GenerateRandomImage<unsigned char>(3u, 3u);
110 MITK_ASSERT_NOT_EQUAL(m_Image, m_AnotherImage,
"We compare two random images. Result should be false.");
113 void Equal_EpsilonDifference_ReturnsTrue()
115 m_Image = mitk::ImageGenerator::GenerateRandomImage<double>(10, 10);
116 m_AnotherImage = m_Image->Clone();
118 CPPUNIT_ASSERT_MESSAGE(
"Epsilon = 0.0 --> double images should not be regarded as equal",
120 CPPUNIT_ASSERT_MESSAGE(
"Epsilon = 0.001 --> double images should be regarded as equal",
121 mitk::Equal(*m_Image, *m_AnotherImage, 0.001,
true));
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
#define MITK_ASSERT_NOT_EQUAL(OBJ1, OBJ2, MSG)
Testing macro to test if two objects are not equal.
Test fixture for parameterized tests.
#define MITK_ASSERT_EQUAL(EXPECTED, ACTUAL, MSG)
Testing macro to test if two objects are equal.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
MITKCORE_EXPORT const ScalarType eps