29 CPPUNIT_TEST_SUITE(mitkCompositePixelValueToStringTestSuite);
30 MITK_TEST(TestConvertRGBUnsignedChar2D_CorrectResult);
31 MITK_TEST(TestConvertRGBUnsignedChar3D_CorrectResult);
32 MITK_TEST(TestConvertRGBAUnsignedChar2D_CorrectResult);
33 MITK_TEST(TestConvertRGBAUnsignedChar3D_CorrectResult);
36 MITK_TEST(TestConvertRGBIndexOutside_NoResult);
37 MITK_TEST(TestConvertNullImage_Exception);
39 CPPUNIT_TEST_SUITE_END();
43 void setUp()
override {}
44 void TestConvertRGBUnsignedChar2D_CorrectResult()
46 typedef itk::RGBPixel<unsigned char>
PixelType;
47 typedef itk::Image<PixelType, 2>
ImageType;
49 ImageType::RegionType region;
50 ImageType::IndexType start;
53 ImageType::SizeType size;
57 region.SetIndex(start);
60 image->SetRegions(region);
63 ImageType::IndexType pixelIndex;
67 rgbPixel.Set(0, 125, 250);
69 image->SetPixel(pixelIndex, rgbPixel);
72 mitkImage->InitializeByItk(image.GetPointer());
73 mitkImage->SetVolume(image->GetBufferPointer());
75 std::string pixelValue;
81 CPPUNIT_ASSERT(pixelValue.compare(
"0 125 250") == 0);
84 void TestConvertRGBUnsignedChar3D_CorrectResult()
86 typedef itk::RGBPixel<unsigned char>
PixelType;
87 typedef itk::Image<PixelType, 3>
ImageType;
89 ImageType::RegionType region;
90 ImageType::IndexType start;
93 ImageType::SizeType size;
97 region.SetIndex(start);
100 image->SetRegions(region);
103 ImageType::IndexType pixelIndex;
107 rgbPixel.Set(0, 125, 250);
109 image->SetPixel(pixelIndex, rgbPixel);
112 mitkImage->InitializeByItk(image.GetPointer());
113 mitkImage->SetVolume(image->GetBufferPointer());
115 std::string pixelValue;
121 CPPUNIT_ASSERT(pixelValue.compare(
"0 125 250") == 0);
124 void TestConvertRGBAUnsignedChar2D_CorrectResult()
126 typedef itk::RGBAPixel<unsigned char>
PixelType;
127 typedef itk::Image<PixelType, 2>
ImageType;
129 ImageType::RegionType region;
130 ImageType::IndexType start;
133 ImageType::SizeType size;
136 region.SetSize(size);
137 region.SetIndex(start);
140 image->SetRegions(region);
143 ImageType::IndexType pixelIndex;
147 rgbPixel.Set(0, 125, 250, 42);
149 image->SetPixel(pixelIndex, rgbPixel);
152 mitkImage->InitializeByItk(image.GetPointer());
153 mitkImage->SetVolume(image->GetBufferPointer());
155 std::string pixelValue;
161 CPPUNIT_ASSERT(pixelValue.compare(
"0 125 250 42") == 0);
164 void TestConvertRGBAUnsignedChar3D_CorrectResult()
166 typedef itk::RGBAPixel<unsigned char>
PixelType;
167 typedef itk::Image<PixelType, 3>
ImageType;
169 ImageType::RegionType region;
170 ImageType::IndexType start;
173 ImageType::SizeType size;
176 region.SetSize(size);
177 region.SetIndex(start);
180 image->SetRegions(region);
183 ImageType::IndexType pixelIndex;
187 rgbPixel.Set(0, 125, 250, 42);
189 image->SetPixel(pixelIndex, rgbPixel);
192 mitkImage->InitializeByItk(image.GetPointer());
193 mitkImage->SetVolume(image->GetBufferPointer());
195 std::string pixelValue;
201 CPPUNIT_ASSERT(pixelValue.compare(
"0 125 250 42") == 0);
204 void TestConvertRGBLong_Exception()
207 typedef itk::Image<PixelType, 3>
ImageType;
209 ImageType::RegionType region;
210 ImageType::IndexType start;
213 ImageType::SizeType size;
216 region.SetSize(size);
217 region.SetIndex(start);
220 image->SetRegions(region);
223 ImageType::IndexType pixelIndex;
227 rgbPixel.Set(0, 125, 250, 42);
229 image->SetPixel(pixelIndex, rgbPixel);
232 mitkImage->InitializeByItk(image.GetPointer());
233 mitkImage->SetVolume(image->GetBufferPointer());
235 std::string pixelValue;
242 void TestConvertInt_Exception()
246 ImageType::RegionType region;
247 ImageType::IndexType start;
250 ImageType::SizeType size;
253 region.SetSize(size);
254 region.SetIndex(start);
257 image->SetRegions(region);
260 ImageType::IndexType pixelIndex;
265 image->SetPixel(pixelIndex, pixel);
268 mitkImage->InitializeByItk(image.GetPointer());
269 mitkImage->SetVolume(image->GetBufferPointer());
271 std::string pixelValue;
278 void TestConvertRGBIndexOutside_NoResult()
280 typedef itk::RGBPixel<unsigned char>
PixelType;
281 typedef itk::Image<PixelType, 2>
ImageType;
283 ImageType::RegionType region;
284 ImageType::IndexType start;
287 ImageType::SizeType size;
290 region.SetSize(size);
291 region.SetIndex(start);
294 image->SetRegions(region);
297 ImageType::IndexType pixelIndex;
301 rgbPixel.Set(0, 125, 250);
303 image->SetPixel(pixelIndex, rgbPixel);
306 mitkImage->InitializeByItk(image.GetPointer());
307 mitkImage->SetVolume(image->GetBufferPointer());
309 std::string pixelValue;
315 CPPUNIT_ASSERT(pixelValue.compare(
"Out of bounds") == 0);
318 void TestConvertNullImage_Exception()
322 std::string pixelValue;
itk::SmartPointer< Self > Pointer
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
std::string MITKCORE_EXPORT ConvertCompositePixelValueToString(Image::Pointer image, itk::Index< 3 > index)
Converts composite pixel values to a displayable string.
map::core::discrete::Elements< 3 >::InternalImageType ImageType
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Test fixture for parameterized tests.
Exception class thrown in AccessByItk macros.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.