14 #include "itkImageRegionIterator.h" 26 typedef std::vector<int> InputPixelArrayType;
27 typedef std::vector<int> OutputPixelArrayType;
32 secondOutputSelection = 0;
37 int secondOutputSelection;
39 unsigned int GetNumberOfOutputs()
const 44 bool operator!=(
const TestFunctor & other)
const 46 return !(*
this == other);
49 bool operator==(
const TestFunctor & other )
const 51 return secondOutputSelection == other.secondOutputSelection;
54 inline OutputPixelArrayType operator()(
const InputPixelArrayType & value,
const IndexType& currentIndex )
const 56 OutputPixelArrayType result;
59 for (InputPixelArrayType::const_iterator pos = value.begin(); pos != value.end(); ++pos)
64 result.push_back(sum);
65 result.push_back(value[secondOutputSelection]);
66 result.push_back(currentIndex[0]);
67 result.push_back(currentIndex[1]);
84 mitk::TestImageType::IndexType testIndex1;
88 mitk::TestImageType::IndexType testIndex2;
92 mitk::TestImageType::IndexType testIndex3;
96 mitk::TestImageType::IndexType testIndex4;
100 mitk::TestImageType::IndexType testIndex5;
106 FilterType::Pointer testFilter = FilterType::New();
108 testFilter->SetInput(0,img1);
109 testFilter->SetInput(1,img2);
110 testFilter->SetInput(2,img3);
112 testFilter->SetNumberOfThreads(2);
114 testFilter->Update();
116 mitk::TestImageType::Pointer out1 = testFilter->GetOutput(0);
117 mitk::TestImageType::Pointer out2 = testFilter->GetOutput(1);
118 mitk::TestImageType::Pointer out3 = testFilter->GetOutput(2);
119 mitk::TestImageType::Pointer out4 = testFilter->GetOutput(3);
121 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #1 (functor #1)",111 == out1->GetPixel(testIndex1));
122 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #2 (functor #1)",333 == out1->GetPixel(testIndex2));
123 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #3 (functor #1)",444 == out1->GetPixel(testIndex3));
124 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #4 (functor #1)",555 == out1->GetPixel(testIndex4));
125 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #5 (functor #1)",999 == out1->GetPixel(testIndex5));
127 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #1 (functor #1)",1 == out2->GetPixel(testIndex1));
128 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #2 (functor #1)",3 == out2->GetPixel(testIndex2));
129 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #3 (functor #1)",4 == out2->GetPixel(testIndex3));
130 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #4 (functor #1)",5 == out2->GetPixel(testIndex4));
131 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #5 (functor #1)",9 == out2->GetPixel(testIndex5));
133 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #1 (functor #1)",0 == out3->GetPixel(testIndex1));
134 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #2 (functor #1)",2 == out3->GetPixel(testIndex2));
135 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #3 (functor #1)",0 == out3->GetPixel(testIndex3));
136 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #4 (functor #1)",1 == out3->GetPixel(testIndex4));
137 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #5 (functor #1)",2 == out3->GetPixel(testIndex5));
139 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #1 (functor #1)",0 == out4->GetPixel(testIndex1));
140 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #2 (functor #1)",0 == out4->GetPixel(testIndex2));
141 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #3 (functor #1)",1 == out4->GetPixel(testIndex3));
142 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #4 (functor #1)",1 == out4->GetPixel(testIndex4));
143 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #5 (functor #1)",2 == out4->GetPixel(testIndex5));
147 funct2.secondOutputSelection = 1;
149 testFilter->SetFunctor(funct2);
151 testFilter->Update();
153 out1 = testFilter->GetOutput(0);
154 out2 = testFilter->GetOutput(1);
155 out3 = testFilter->GetOutput(2);
156 out4 = testFilter->GetOutput(3);
158 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #1 (functor #2)",111 == out1->GetPixel(testIndex1));
159 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #2 (functor #2)",333 == out1->GetPixel(testIndex2));
160 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #3 (functor #2)",444 == out1->GetPixel(testIndex3));
161 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #4 (functor #2)",555 == out1->GetPixel(testIndex4));
162 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #1 index #5 (functor #2)",999 == out1->GetPixel(testIndex5));
164 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #1 (functor #2)",10 == out2->GetPixel(testIndex1));
165 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #2 (functor #2)",30 == out2->GetPixel(testIndex2));
166 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #3 (functor #2)",40 == out2->GetPixel(testIndex3));
167 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #4 (functor #2)",50 == out2->GetPixel(testIndex4));
168 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #2 index #5 (functor #2)",90 == out2->GetPixel(testIndex5));
170 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #1 (functor #2)",0 == out3->GetPixel(testIndex1));
171 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #2 (functor #2)",2 == out3->GetPixel(testIndex2));
172 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #3 (functor #2)",0 == out3->GetPixel(testIndex3));
173 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #4 (functor #2)",1 == out3->GetPixel(testIndex4));
174 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #3 index #5 (functor #2)",2 == out3->GetPixel(testIndex5));
176 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #1 (functor #2)",0 == out4->GetPixel(testIndex1));
177 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #2 (functor #2)",0 == out4->GetPixel(testIndex2));
178 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #3 (functor #2)",1 == out4->GetPixel(testIndex3));
179 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #4 (functor #2)",1 == out4->GetPixel(testIndex4));
180 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of output #4 index #5 (functor #2)",2 == out4->GetPixel(testIndex5));
184 testFilter->SetMask(mask);
186 testFilter->Update();
188 out1 = testFilter->GetOutput(0);
189 out2 = testFilter->GetOutput(1);
190 out3 = testFilter->GetOutput(2);
191 out4 = testFilter->GetOutput(3);
193 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #1 index #1 (functor #2)",0 == out1->GetPixel(testIndex1));
194 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #1 index #2 (functor #2)",333 == out1->GetPixel(testIndex2));
195 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #1 index #3 (functor #2)",444 == out1->GetPixel(testIndex3));
196 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #1 index #4 (functor #2)",0 == out1->GetPixel(testIndex4));
197 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #1 index #5 (functor #2)",0 == out1->GetPixel(testIndex5));
199 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #2 index #1 (functor #2)",0 == out2->GetPixel(testIndex1));
200 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #2 index #2 (functor #2)",30 == out2->GetPixel(testIndex2));
201 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #2 index #3 (functor #2)",40 == out2->GetPixel(testIndex3));
202 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #2 index #4 (functor #2)",0 == out2->GetPixel(testIndex4));
203 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #2 index #5 (functor #2)",0 == out2->GetPixel(testIndex5));
205 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #3 index #1 (functor #2)",0 == out3->GetPixel(testIndex1));
206 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #3 index #2 (functor #2)",2 == out3->GetPixel(testIndex2));
207 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #3 index #3 (functor #2)",0 == out3->GetPixel(testIndex3));
208 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #3 index #4 (functor #2)",0 == out3->GetPixel(testIndex4));
209 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #3 index #5 (functor #2)",0 == out3->GetPixel(testIndex5));
211 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #4 index #1 (functor #2)",0 == out4->GetPixel(testIndex1));
212 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #4 index #2 (functor #2)",0 == out4->GetPixel(testIndex2));
213 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #4 index #3 (functor #2)",1 == out4->GetPixel(testIndex3));
214 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #4 index #4 (functor #2)",0 == out4->GetPixel(testIndex4));
215 CPPUNIT_ASSERT_MESSAGE(
"Check pixel of masked output #4 index #5 (functor #2)",0 == out4->GetPixel(testIndex5));
MITKCORE_EXPORT bool operator!=(const InteractionEvent &a, const InteractionEvent &b)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
TestImageType::Pointer MITKTESTINGHELPER_EXPORT GenerateTestImage(int factor=1)
Perform a generic pixel-wise operation on N images and produces m output images.
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
int itkMultiOutputNaryFunctorImageFilterTest(int, char *[])
mitk::Image::Pointer mask
TestMaskType::Pointer MITKTESTINGHELPER_EXPORT GenerateTestMask()