14 #include "itkImageRegionIterator.h" 33 FilterType::Pointer testFilter = FilterType::New();
35 testFilter->SetInput(img1);
37 testFilter->SetNumberOfThreads(2);
41 FilterType::PixelType
max = testFilter->GetMaximum();
42 FilterType::PixelType
min = testFilter->GetMinimum();
43 FilterType::RealType mean = testFilter->GetMean();
44 FilterType::RealType sig = testFilter->GetSigma();
45 FilterType::RealType variance = testFilter->GetVariance();
46 FilterType::RealType sum = testFilter->GetSum();
48 CPPUNIT_ASSERT_MESSAGE(
"Check computed maximum",9 == max);
49 CPPUNIT_ASSERT_MESSAGE(
"Check computed minimum",1 == min);
50 CPPUNIT_ASSERT_MESSAGE(
"Check computed mean",5 == mean);
51 CPPUNIT_ASSERT_MESSAGE(
"Check computed sigma",sqrt(7.5) == sig);
52 CPPUNIT_ASSERT_MESSAGE(
"Check computed variance",7.5 == variance);
53 CPPUNIT_ASSERT_MESSAGE(
"Check computed sum",45 == sum);
57 testFilter->SetMask(mask);
61 max = testFilter->GetMaximum();
62 min = testFilter->GetMinimum();
63 mean = testFilter->GetMean();
64 sig = testFilter->GetSigma();
65 variance = testFilter->GetVariance();
66 sum = testFilter->GetSum();
68 CPPUNIT_ASSERT_MESSAGE(
"Check computed maximum",4 == max);
69 CPPUNIT_ASSERT_MESSAGE(
"Check computed minimum",2 == min);
70 CPPUNIT_ASSERT_MESSAGE(
"Check computed mean",3 == mean);
71 CPPUNIT_ASSERT_MESSAGE(
"Check computed sigma",1 == sig);
72 CPPUNIT_ASSERT_MESSAGE(
"Check computed variance",1 == variance);
73 CPPUNIT_ASSERT_MESSAGE(
"Check computed sum",9 == sum);
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
TestImageType::Pointer MITKTESTINGHELPER_EXPORT GenerateTestImage(int factor=1)
Compute min. max, variance and mean of an (masked) Image.
int itkMaskedStatisticsImageFilterTest(int, char *[])
mitk::Image::Pointer mask
TestMaskType::Pointer MITKTESTINGHELPER_EXPORT GenerateTestMask()