25 CPPUNIT_TEST_SUITE(mitkImageGeneratorTestSuite);
61 MITK_TEST(SetGradientImageValues_Success);
62 CPPUNIT_TEST_SUITE_END();
77 m_Image2Da = mitk::ImageGenerator::GenerateRandomImage<float>(120, 205, 0, 0, 0.1, 0.2, 0.3, 577, 23);
78 m_Image2Db = mitk::ImageGenerator::GenerateRandomImage<unsigned char>(1, 1, 0, 0);
79 m_Image3Da = mitk::ImageGenerator::GenerateRandomImage<int>(512, 205, 1, 0);
80 m_Image3Db = mitk::ImageGenerator::GenerateRandomImage<double>(512, 532, 112, 0);
81 m_Image4Da = mitk::ImageGenerator::GenerateRandomImage<float>(120, 205, 78, 1);
82 m_Image4Db = mitk::ImageGenerator::GenerateRandomImage<unsigned char>(550, 33, 78, 150);
83 m_Image3Dc = mitk::ImageGenerator::GenerateGradientImage<unsigned int>(1, 2, 3, 4, 5, 6);
96 void SetSpacingX2D_Success()
98 CPPUNIT_ASSERT_MESSAGE(
"Testing if spacing 2D x is set correctly.",
99 fabs(m_Image2Da->GetGeometry()->GetSpacing()[0] - 0.1) < 0.0001);
102 void SetDefaultSpacingX2D_Success()
104 CPPUNIT_ASSERT_MESSAGE(
"Testing if default spacing 2D x is set correctly.",
105 fabs(m_Image2Db->GetGeometry()->GetSpacing()[0] - 1.0) < 0.0001);
108 void SetSpacingX3D_Success()
110 CPPUNIT_ASSERT_MESSAGE(
"Testing if spacing 3D x is set correctly.",
111 fabs(m_Image3Dc->GetGeometry()->GetSpacing()[0] - 4) < 0.0001);
114 void SetSpacingY2D_Success()
116 CPPUNIT_ASSERT_MESSAGE(
"Testing if spacing 2D y is set correctly.",
117 fabs(m_Image2Da->GetGeometry()->GetSpacing()[1] - 0.2) < 0.0001);
120 void SetDefaultSpacingY2D_Success()
122 CPPUNIT_ASSERT_MESSAGE(
"Testing if default spacing 2D y is set correctly.",
123 fabs(m_Image2Db->GetGeometry()->GetSpacing()[1] - 1.0) < 0.0001);
126 void SetSpacingY3D_Success()
128 CPPUNIT_ASSERT_MESSAGE(
"Testing if spacing 3D y is set correctly.",
129 fabs(m_Image3Dc->GetGeometry()->GetSpacing()[1] - 5) < 0.0001);
132 void SetSpacingZ2D_Success()
134 CPPUNIT_ASSERT_MESSAGE(
"Testing if spacing 2D z is set correctly.",
135 fabs(m_Image2Da->GetGeometry()->GetSpacing()[2] - 0.3) < 0.0001);
138 void SetDefaultSpacingZ2D_Success()
140 CPPUNIT_ASSERT_MESSAGE(
"Testing if default spacing 2D z is set correctly.",
141 fabs(m_Image2Db->GetGeometry()->GetSpacing()[2] - 1.0) < 0.0001);
144 void SetSpacingZ3D_Success()
146 CPPUNIT_ASSERT_MESSAGE(
"Testing if spacing z is set correctly.",
147 fabs(m_Image3Dc->GetGeometry()->GetSpacing()[2] - 6) < 0.0001);
150 void SetDimension2D_Success()
152 CPPUNIT_ASSERT_MESSAGE(
"Testing if the dimension 2D is set correctly.", m_Image2Da->GetDimension() == 2);
153 CPPUNIT_ASSERT_MESSAGE(
"Testing if the dimension 2D is set correctly.", m_Image2Db->GetDimension() == 2);
156 void SetDimension3D_Success()
158 CPPUNIT_ASSERT_MESSAGE(
"Testing if the dimension 3D is set correctly.",m_Image3Da->GetDimension() == 2);
159 CPPUNIT_ASSERT_MESSAGE(
"Testing if the dimension 3D is set correctly.", m_Image3Db->GetDimension() == 3);
162 void SetDimension4D_Success()
164 CPPUNIT_ASSERT_MESSAGE(
"Testing if the dimension 4D is set correctly.", m_Image4Da->GetDimension() == 3);
165 CPPUNIT_ASSERT_MESSAGE(
"Testing if the dimension 4D is set correctly.", m_Image4Db->GetDimension() == 4);
168 void SetDimensionX2D_Success()
170 CPPUNIT_ASSERT_MESSAGE(
"Testing if the X dimension of the 2D image is set correctly.", m_Image2Da->GetDimension(0) == 120);
173 void SetDimensionY2D_Success()
175 CPPUNIT_ASSERT_MESSAGE(
"Testing if the Y dimension of the 2D image is set correctly.", m_Image2Db->GetDimension(1) == 1);
178 void SetDimensionZ3D_Success()
180 CPPUNIT_ASSERT_MESSAGE(
"Testing if the Z dimension of the 3D image is set correctly.", m_Image3Da->GetDimension(2) == 1);
181 CPPUNIT_ASSERT_MESSAGE(
"Testing if the Z dimension of the 3D image is set correctly.", m_Image3Db->GetDimension(2) == 112);
184 void SetDimensionT4D_Success()
186 CPPUNIT_ASSERT_MESSAGE(
"Testing if the T dimension of the 4D image is set correctly.", m_Image4Da->GetDimension(3) == 1);
187 CPPUNIT_ASSERT_MESSAGE(
"Testing if the T dimension of the 4D image is set correctly.", m_Image4Db->GetDimension(3) == 150);
190 void SetDimensions3Dc_Success()
192 CPPUNIT_ASSERT_MESSAGE(
"Testing if image3Dc dimension x is set correctly.", m_Image3Dc->GetDimension(0) == 1);
193 CPPUNIT_ASSERT_MESSAGE(
"Testing if image3Dc dimension y is set correctly.", m_Image3Dc->GetDimension(1) == 2);
194 CPPUNIT_ASSERT_MESSAGE(
"Testing if image3Dc dimension z is set correctly.", m_Image3Dc->GetDimension(2) == 3);
197 void SetDataTypeFloat2D_Success()
199 CPPUNIT_ASSERT_MESSAGE(
"Testing if the data type for a float 3D image is set correctly.",
200 m_Image2Da->GetPixelType().GetComponentType() == itk::ImageIOBase::FLOAT);
203 void SetDataTypeUChar2D_Success()
205 CPPUNIT_ASSERT_MESSAGE(
"Testing if the data type for a UChar 2D image is set correctly.",
206 m_Image2Db->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR);
209 void SetDataTypeInt3D_Success()
211 CPPUNIT_ASSERT_MESSAGE(
"Testing if the data type for a Int 3D image is set correctly.",
212 m_Image3Da->GetPixelType().GetComponentType() == itk::ImageIOBase::INT);
215 void SetDataTypeDouble3D_Success()
217 CPPUNIT_ASSERT_MESSAGE(
"Testing if the data type for a Double 3D image is set correctly.",
218 m_Image3Db->GetPixelType().GetComponentType() == itk::ImageIOBase::DOUBLE);
221 void SetDataTypeFloat4D_Success()
223 CPPUNIT_ASSERT_MESSAGE(
"Testing if the data type for a Float 4D image is set correctly.",
224 m_Image4Da->GetPixelType().GetComponentType() == itk::ImageIOBase::FLOAT);
227 void SetDataTypeUChar4D_Success()
229 CPPUNIT_ASSERT_MESSAGE(
"Testing if the data type for a UChar 4D image is set correctly.",
230 m_Image4Db->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR);
233 void SetDataTypeUInt3D_Success()
235 CPPUNIT_ASSERT_MESSAGE(
"Testing if the data type for a UInt 3D image is set correctly.",
236 m_Image3Dc->GetPixelType().GetComponentType() == itk::ImageIOBase::UINT);
239 void SetPixelTypeFloat2D_Success()
241 itk::ImageIOBase::IOPixelType scalarType = itk::ImageIOBase::SCALAR;
242 CPPUNIT_ASSERT_MESSAGE(
"Testing if the pixel type for a Float 2D image is set correctly.",
243 m_Image2Da->GetPixelType().GetPixelType() == scalarType);
246 void SetPixelTypeUChar2D_Success()
248 itk::ImageIOBase::IOPixelType scalarType = itk::ImageIOBase::SCALAR;
249 CPPUNIT_ASSERT_MESSAGE(
"Testing if the pixel type for a UChar 2D image is set correctly.",
250 m_Image2Db->GetPixelType().GetPixelType() == scalarType);
253 void SetPixelTypeInt3D_Success()
255 itk::ImageIOBase::IOPixelType scalarType = itk::ImageIOBase::SCALAR;
256 CPPUNIT_ASSERT_MESSAGE(
"Testing if the pixel type for a Int 3D image is set correctly.",
257 m_Image3Da->GetPixelType().GetPixelType() == scalarType);
260 void SetPixelTypeDouble3D_Success()
262 itk::ImageIOBase::IOPixelType scalarType = itk::ImageIOBase::SCALAR;
263 CPPUNIT_ASSERT_MESSAGE(
"Testing if the pixel type for a Double 3D image is set correctly.",
264 m_Image3Db->GetPixelType().GetPixelType() == scalarType);
267 void SetPixelTypeFloat4D_Success()
269 itk::ImageIOBase::IOPixelType scalarType = itk::ImageIOBase::SCALAR;
270 CPPUNIT_ASSERT_MESSAGE(
"Testing if the pixel type for a Float 4D image is set correctly.",
271 m_Image4Da->GetPixelType().GetPixelType() == scalarType);
274 void SetPixelTypeUChar4D_Success()
276 itk::ImageIOBase::IOPixelType scalarType = itk::ImageIOBase::SCALAR;
277 CPPUNIT_ASSERT_MESSAGE(
"Testing if the pixel type for a UChar 4D image is set correctly.",
278 m_Image4Db->GetPixelType().GetPixelType() == scalarType);
281 void SetPixelTypeUInt3D_Success()
283 itk::ImageIOBase::IOPixelType scalarType = itk::ImageIOBase::SCALAR;
284 CPPUNIT_ASSERT_MESSAGE(
"Testing if the pixel type for a UInt 3D image is set correctly.",
285 m_Image3Dc->GetPixelType().GetPixelType() == scalarType);
288 void MaxValueHolds_Success()
290 CPPUNIT_ASSERT_MESSAGE(
"Testing if max value holds", m_Image2Da->GetStatistics()->GetScalarValueMax() <= 577);
293 void MinValueHolds_Success()
295 CPPUNIT_ASSERT_MESSAGE(
"Testing if min value holds", m_Image2Da->GetStatistics()->GetScalarValueMin() >= 23);
298 void DefaultMaxValueHolds_Success()
300 CPPUNIT_ASSERT_MESSAGE(
"Testing if default max value holds", m_Image3Da->GetStatistics()->GetScalarValueMax() <= 1000);
303 void DefaultMinValueHolds_Success()
305 CPPUNIT_ASSERT_MESSAGE(
"Testing if default min value holds", m_Image3Da->GetStatistics()->GetScalarValueMin() >= 0);
308 void SetGradientImageValues_Success()
310 const unsigned int *image3DcBuffer =
nullptr;
314 image3DcBuffer =
static_cast<const unsigned int *
>(readAccess.GetData());
318 MITK_ERROR <<
"Read access not granted on mitk::Image.";
320 for (
unsigned int i = 0; i < 2 * 3; i++)
322 CPPUNIT_ASSERT_MESSAGE(
"Testing if gradient image values are set correctly", image3DcBuffer[i] == i);
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
Test fixture for parameterized tests.
ImageReadAccessor class to get locked read access for a particular image part.