17 #include "itkDiffusionTensor3D.h"
43 planegeometry->InitializeStandardPlane(100, 100, right, bottom, &spacing);
44 planegeometry->SetOrigin(origin);
47 imgMem->Initialize(pt, 40, *planegeometry);
54 CPPUNIT_TEST_SUITE(mitkImageToItkTestSuite);
55 MITK_TEST(ImageCastIntToFloat_EmptyImage);
56 MITK_TEST(ImageCastDoubleToFloat_EmptyImage);
57 MITK_TEST(ImageCastFloatToFloatTensor_EmptyImage_ThrowsException);
58 MITK_TEST(ImageCastFloatTensorToFloatTensor_EmptyImage);
59 MITK_TEST(ImageCastDoubleToTensorDouble_EmptyImage_ThrowsException);
60 MITK_TEST(ImageCastToItkAndBack_SamePointer_Success);
61 MITK_TEST(ImageCastToItk_TestImage_Success);
62 CPPUNIT_TEST_SUITE_END();
73 void tearDown()
override { m_TestImage =
nullptr; }
74 void ImageCastIntToFloat_EmptyImage()
82 CPPUNIT_ASSERT_MESSAGE(
"Cast output is not null", mitkImageAfterCast.IsNotNull());
85 void ImageCastDoubleToFloat_EmptyImage()
92 CPPUNIT_ASSERT_MESSAGE(
"Casting scalar double (MITK) image to scalar float tensor (ITK). Result shouldn't be NULL.",
93 diffImage.IsNotNull());
96 void ImageCastFloatToFloatTensor_EmptyImage_ThrowsException()
99 itk::Image<itk::DiffusionTensor3D<float>, 3>
::Pointer diffImage;
101 CPPUNIT_ASSERT_THROW_MESSAGE(
"Casting scalar float (MITK) image to scalar float (ITK) throws exception.",
106 void ImageCastFloatTensorToFloatTensor_EmptyImage()
108 typedef itk::Image<itk::DiffusionTensor3D<float>, 3> ItkTensorImageType;
110 itk::Image<itk::DiffusionTensor3D<float>, 3>
::Pointer diffImage;
114 "Casting float tensor (MITK) image to float tensor (ITK). Result shouldn't be NULL");
117 MITK_ASSERT_EQUAL(mitkImageAfterCast, m_TestImage,
"Same type, images shoul be equal.");
120 void ImageCastDoubleToTensorDouble_EmptyImage_ThrowsException()
123 itk::Image<itk::DiffusionTensor3D<double>, 3>
::Pointer diffImage;
128 void ImageCastToItkAndBack_SamePointer_Success()
130 typedef itk::Image<short, 3> ItkImageType;
137 itk::Matrix<double, 3, 3> dir = itkImage->GetDirection();
139 itkImage->SetDirection(dir);
141 CPPUNIT_ASSERT_THROW_MESSAGE(
"No exception thrown for casting back the same memory",
143 itk::ExceptionObject);
144 CPPUNIT_ASSERT(testDataImage.IsNotNull());
147 void ImageCastToItk_TestImage_Success()
159 MITK_ASSERT_EQUAL(mitkImageAfterCast, testDataImage,
"Cast with test data followed by import produces same images");
itk::SmartPointer< Self > Pointer
static mitk::Image::Pointer GetEmptyTestImageWithGeometry(mitk::PixelType pt)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static std::string GetTestDataFilePath(const std::string &testData)
Get the absolute path for test data.
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
Image::Pointer ImportItkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, const BaseGeometry *geometry=nullptr, bool update=true)
Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImpor...
Image::Pointer GrabItkImageMemory(itk::SmartPointer< ItkOutputImageType > &itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.
Test fixture for parameterized tests.
#define MITK_ASSERT_EQUAL(EXPECTED, ACTUAL, MSG)
Testing macro to test if two objects are equal.
Exception class thrown in AccessByItk macros.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
Class for defining the data type of pixels.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.