23 #include <itkVectorImage.h> 25 #include <vtkDebugLeaks.h> 27 struct MyObscurePixelType
30 static const size_t Length = 2;
37 CPPUNIT_TEST_SUITE(mitkPixelTypeTestSuite);
42 MITK_TEST(GetNumberOfComponentsPtype_Success);
43 MITK_TEST(GetBitsPerComponentPtype_Success);
45 MITK_TEST(GetNumberOfComponentsItkPtype_Success);
46 MITK_TEST(GetBitsPerComponentItkPtype_Success);
47 MITK_TEST(ConstructorWithBrackets_Success);
48 MITK_TEST(InitializeWithEqualSign_Success);
56 MITK_TEST(ImageTypeTraitVectorShort3D_Success);
57 MITK_TEST(ImageTypeTraitItkInt3D_Success);
58 MITK_TEST(ImageTypeTraitItkShort2D_Success);
59 MITK_TEST(ImageTypeTraitItkVectorShort3D_Success);
61 CPPUNIT_TEST_SUITE_END();
64 typedef itk::Image<itk::FixedArray<int, 5>, 3> ItkImageType;
65 typedef itk::Image<MyObscurePixelType> MyObscureImageType;
66 typedef itk::VectorImage<short, 3> VectorImageType;
67 typedef itk::Image<itk::Vector<short, 7>> FixedVectorImageType;
75 void tearDown()
override 79 void GetComponentType_Success()
82 MITK_INFO <<
"m_Ptype = mitk::MakePixelType<int, int, 5>();";
84 <<
"m_ItkPtype = mitk::MakePixelType<ItkImageType>();\n with itk::Image<itk::FixedArray< int, 5>, 3> ItkImageType";
85 CPPUNIT_ASSERT_MESSAGE(
"GetComponentType()", ptype.
GetComponentType() == itk::ImageIOBase::INT);
88 void GetPixelTypeAsString_Success()
92 MITK_INFO <<
typeid(ItkImageType).name();
95 void GetBpePtype_Success()
98 CPPUNIT_ASSERT_MESSAGE(
"[m_Ptype] GetBpe()", ptype.
GetBpe() == 8 *
sizeof(int) * 5);
101 void GetNumberOfComponentsPtype_Success()
107 void GetBitsPerComponentPtype_Success()
110 CPPUNIT_ASSERT_MESSAGE(
"[ptype]GetBitsPerComponent()", ptype.
GetBitsPerComponent() == 8 *
sizeof(int));
113 void GetBpeItkPtype_Success()
116 CPPUNIT_ASSERT_MESSAGE(
"[itkPType] GetBpe()", itkPtype.
GetBpe() == 8 *
sizeof(int) * 5);
119 void GetNumberOfComponentsItkPtype_Success()
125 void GetBitsPerComponentItkPtype_Success()
128 CPPUNIT_ASSERT_MESSAGE(
"[itkPType] GetBitsPerComponent()", itkPtype.
GetBitsPerComponent() == 8 *
sizeof(int));
131 void ConstructorWithBrackets_Success()
135 CPPUNIT_ASSERT_MESSAGE(
"ptype2( ptype)- GetComponentType()", ptype2.GetComponentType() == itk::ImageIOBase::INT);
136 CPPUNIT_ASSERT_MESSAGE(
"ptype2( ptype)-GetPixelType(", ptype2.GetPixelType() == ptype.
GetPixelType());
137 CPPUNIT_ASSERT_MESSAGE(
"ptype2( ptype)-GetComponentType(", ptype2.GetComponentType() == ptype.
GetComponentType());
138 CPPUNIT_ASSERT_MESSAGE(
"ptype2( ptype)-GetBpe()", ptype2.GetBpe() == 8 *
sizeof(int) * 5);
139 CPPUNIT_ASSERT_MESSAGE(
"ptype2( ptype)-GetNumberOfComponents()", ptype2.GetNumberOfComponents() == 5);
140 CPPUNIT_ASSERT_MESSAGE(
"ptype2( ptype)-GetBitsPerComponent()", ptype2.GetBitsPerComponent() == 8 *
sizeof(int));
143 void InitializeWithEqualSign_Success()
147 CPPUNIT_ASSERT_MESSAGE(
"ptype2 = ptype- GetComponentType()", ptype2.GetComponentType() == itk::ImageIOBase::INT);
148 CPPUNIT_ASSERT_MESSAGE(
"ptype2 = ptype- GetPixelType(", ptype2.GetPixelType() == ptype.
GetPixelType());
149 CPPUNIT_ASSERT_MESSAGE(
"ptype2( ptype)-GetComponentType(", ptype2.GetComponentType() == ptype.
GetComponentType());
150 CPPUNIT_ASSERT_MESSAGE(
"ptype2 = ptype- GetBpe()", ptype2.GetBpe() == 8 *
sizeof(int) * 5);
151 CPPUNIT_ASSERT_MESSAGE(
"ptype2 = ptype- GetNumberOfComponents()", ptype2.GetNumberOfComponents() == 5);
152 CPPUNIT_ASSERT_MESSAGE(
"ptype2 = ptype- GetBitsPerComponent()", ptype2.GetBitsPerComponent() == 8 *
sizeof(int));
155 void EqualityOperator_Success()
159 CPPUNIT_ASSERT_MESSAGE(
"operator ==", ptype == ptype2);
162 void NotEqualityOperator_Success()
166 CPPUNIT_ASSERT_MESSAGE(
"operator !=", ptype != ptype3);
169 void GetPixelTypeUnknown_Success()
172 mitk::PixelType obscurePixelType = mitk::MakePixelType<MyObscureImageType>();
173 CPPUNIT_ASSERT_MESSAGE(
"PixelTypeId is 'UNKNOWN' ", obscurePixelType.
GetPixelType() == itk::ImageIOBase::UNKNOWNPIXELTYPE);
176 void SetLengthCorrectly_Success()
178 mitk::PixelType obscurePixelType = mitk::MakePixelType<MyObscureImageType>();
179 CPPUNIT_ASSERT_MESSAGE(
"Lenght was set correctly", obscurePixelType.
GetNumberOfComponents() == MyObscurePixelType::Length);
182 void ValueTypeCorresponds_Success()
184 mitk::PixelType obscurePixelType = mitk::MakePixelType<MyObscureImageType>();
185 CPPUNIT_ASSERT_MESSAGE(
"ValueType corresponds.",
190 void ImageTypeTraitInt3D_Success()
193 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait typeid int 3D equals ITK typeid",
199 void ImageTypeTraitShort2D_Success()
201 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait typeid short 2D equals ITK typeid",
203 typeid(
itk::Image<itk::FixedArray<short, 2>, 3>));
204 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait is no vector image", (
mitk::ImageTypeTrait<itk::FixedArray<short, 2>, 3>::IsVectorImage ==
false));
207 void ImageTypeTraitVectorShort3D_Success()
209 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait typeid short 3D equals ITK typeid",
214 void ImageTypeTraitItkInt3D_Success()
216 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait typeid ITK int 3D equals ITK typeid",
218 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait is no vector image", (
mitk::ImageTypeTrait<itk::Image<int, 3>>::IsVectorImage ==
false));
221 void ImageTypeTraitItkShort2D_Success()
223 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait typeid ITK short 2D equals ITK typeid",
225 typeid(
itk::Image<itk::FixedArray<short, 2>, 3>));
226 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait is no vector image",
231 void ImageTypeTraitItkVectorShort3D_Success()
233 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait typeid ITK short 3D equals ITK typeid",
235 CPPUNIT_ASSERT_MESSAGE(
"ImageTypeTrait is a vector image",
vcl_size_t GetBitsPerComponent() const
Get the number of bits per components.
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
itk::Image< unsigned char, 3 > ImageType
vcl_size_t GetNumberOfComponents() const
Get the number of components of which each element consists.
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
itk::Image< TPixelType, VDimension > ImageType
vcl_size_t GetBpe() const
Get the number of bits per element (of an element)
int GetComponentType() const
Get the component type (the scalar (!) type). Each element may contain m_NumberOfComponents (more tha...
ValueType
Type of the value held by a Value object.
Test fixture for parameterized tests.
itk::ImageIOBase::IOPixelType GetPixelType() const
std::string GetPixelTypeAsString() const
Returns a string containing the ITK pixel type name.
Class for defining the data type of pixels.