19 #include <itksys/SystemTools.hxx>
27 return (std::fabs(val1 - val2) <= epsilon);
34 std::cout <<
"no path to testing specified [FAILED]" << std::endl;
38 std::string fileIn = argv[1];
39 std::cout <<
"Eingabe Datei: " << fileIn << std::endl;
41 if (image->GetPixelType() !=
mitk::PixelType(mitk::MakeScalarPixelType<char>()) ||
42 image->GetPixelType() !=
mitk::PixelType(mitk::MakeScalarPixelType<unsigned char>()))
44 std::cout <<
"file not a char or unsigned char image - test will not be applied [PASSED]" << std::endl;
45 std::cout <<
"[TEST DONE]" << std::endl;
49 std::cout <<
"Testing instantiation: ";
53 std::cout <<
"[FAILED]" << std::endl;
58 std::cout <<
"[PASSED]" << std::endl;
61 std::cout <<
"Create surface with default settings: ";
62 filter->SetInput(image);
65 if (filter->GetNumberOfOutputs() != 1)
67 std::cout <<
"Wrong number of outputs, [FAILED]" << std::endl;
70 else if (filter->GetOutput() == NULL)
72 std::cout <<
"Output is NULL, [FAILED]" << std::endl;
75 else if (filter->GetOutput()->GetVtkPolyData() == NULL)
77 std::cout <<
"PolyData of surface is NULL, [FAILED]" << std::endl;
82 std::cout <<
"[PASSED]" << std::endl;
85 std::cout <<
"Testing index to label conversion: ";
86 if (filter->GetLabelForNthOutput(0) != 257)
88 std::cout <<
"[FAILED]" << std::endl;
93 std::cout <<
"[PASSED]" << std::endl;
96 std::cout <<
"Testing volume for label calculation: ";
97 if (!
equals(filter->GetVolumeForLabel(257), 14.328))
99 std::cout << filter->GetVolumeForLabel(257) <<
"[FAILED]" << std::endl;
104 std::cout <<
"[PASSED]" << std::endl;
107 std::cout <<
"Testing volume for index calculation: ";
108 if (!
equals(filter->GetVolumeForNthOutput(0), 14.328))
110 std::cout <<
"[FAILED]" << std::endl;
115 std::cout <<
"[PASSED]" << std::endl;
118 std::cout <<
"Create surface using optimised settings: ";
119 filter->GenerateAllLabelsOn();
120 filter->SetGaussianStandardDeviation(1.5);
121 filter->SetSmooth(
true);
123 filter->SetTargetReduction(0.8);
124 if (filter->GetNumberOfOutputs() != 1)
126 std::cout <<
"[FAILED]" << std::endl;
131 std::cout <<
"[PASSED]" << std::endl;
134 std::cout <<
"Create surface for label 257: ";
135 filter->GenerateAllLabelsOff();
136 filter->SetLabel(257);
138 if (filter->GetNumberOfOutputs() != 1)
140 std::cout <<
"Wrong number of outputs, [FAILED]" << std::endl;
143 else if (filter->GetOutput() == NULL)
145 std::cout <<
"Output is NULL, [FAILED]" << std::endl;
148 else if (filter->GetOutput()->GetVtkPolyData() == NULL)
150 std::cout <<
"PolyData of surface is NULL, [FAILED]" << std::endl;
155 std::cout <<
"[PASSED]" << std::endl;
158 std::cout <<
"Testing volume for label calculation: ";
159 if (!
equals(filter->GetVolumeForLabel(257), 14.328))
161 std::cout <<
"[FAILED]" << std::endl;
166 std::cout <<
"[PASSED]" << std::endl;
169 std::cout <<
"Testing volume for index calculation: ";
170 if (!
equals(filter->GetVolumeForNthOutput(0), 14.328))
172 std::cout <<
"[FAILED]" << std::endl;
177 std::cout <<
"[PASSED]" << std::endl;
180 std::cout <<
"Create surface for multiple labels: ";
181 filter->GenerateAllLabelsOn();
182 filter->SetBackgroundLabel(32000);
184 if (filter->GetNumberOfOutputs() != 2)
186 std::cout <<
"Wrong number of outputs, [FAILED]" << std::endl;
189 else if (filter->GetOutput() == NULL)
191 std::cout <<
"Output 0 is NULL, [FAILED]" << std::endl;
194 else if (filter->GetOutput()->GetVtkPolyData() == NULL)
196 std::cout <<
"PolyData of output 0 is NULL, [FAILED]" << std::endl;
199 else if (filter->GetOutput(1) == NULL)
201 std::cout <<
"Output 1 is NULL, [FAILED]" << std::endl;
204 else if (filter->GetOutput(1)->GetVtkPolyData() == NULL)
206 std::cout <<
"PolyData of output 1 is NULL, [FAILED]" << std::endl;
211 std::cout <<
"[PASSED]" << std::endl;
214 std::cout <<
"Testing volume for label calculation: ";
215 if (!
equals(filter->GetVolumeForLabel(257), 14.328))
217 std::cout <<
"[FAILED]" << std::endl;
220 else if (!
equals(filter->GetVolumeForLabel(0), 12.672))
222 std::cout <<
"[FAILED]" << std::endl;
227 std::cout <<
"[PASSED]" << std::endl;
230 std::cout <<
"Testing volume for index calculation: ";
231 if (!
equals(filter->GetVolumeForNthOutput(1), 14.328))
233 std::cout <<
"[FAILED]" << std::endl;
236 else if (!
equals(filter->GetVolumeForNthOutput(0), 12.672))
238 std::cout <<
"[FAILED]" << std::endl;
243 std::cout <<
"[PASSED]" << std::endl;
250 std::cout <<
"Create surface for background (label 0): " << std::flush;
251 filter->GenerateAllLabelsOff();
253 filter->SetBackgroundLabel(257);
259 if (filter->GetNumberOfOutputs() != 1)
261 std::cout <<
"Wrong number of outputs, [FAILED]" << std::endl;
264 else if (filter->GetOutput() == NULL)
266 std::cout <<
"Output is NULL, [FAILED]" << std::endl;
269 else if (filter->GetOutput()->GetVtkPolyData() == NULL)
271 std::cout <<
"PolyData of surface is NULL, [FAILED]" << std::endl;
276 std::cout <<
"[PASSED]" << std::endl;
278 std::cout <<
"Testing reference count correctness of old output 1: " << std::flush;
279 if (outputSurface1Watcher->GetReferenceCount() != 0)
281 std::cout <<
"outputSurface1Watcher->GetReferenceCount()==" << outputSurface1Watcher->GetReferenceCount()
282 <<
"!=0, [FAILED]" << std::endl;
285 std::cout <<
"[PASSED]" << std::endl;
286 std::cout <<
"Testing reference count correctness of filter: " << std::flush;
287 if (filterWatcher->GetReferenceCount() != 2)
289 std::cout <<
"filterWatcher->GetReferenceCount()==" << outputSurface1Watcher->GetReferenceCount() <<
"!=2, [FAILED]"
293 std::cout <<
"[PASSED]" << std::endl;
295 std::cout <<
"Testing index to label conversion: ";
296 if (filter->GetLabelForNthOutput(0) != 0)
298 std::cout <<
"[FAILED]" << std::endl;
303 std::cout <<
"[PASSED]" << std::endl;
306 std::cout <<
"Testing volume for label calculation: ";
307 if (!
equals(filter->GetVolumeForLabel(filter->GetLabel()), 12.672))
309 std::cout <<
"[FAILED]" << std::endl;
314 std::cout <<
"[PASSED]" << std::endl;
317 std::cout <<
"Testing volume for index calculation: ";
318 if (!
equals(filter->GetVolumeForNthOutput(0), 12.672))
320 std::cout <<
"[FAILED]" << std::endl;
325 std::cout <<
"[PASSED]" << std::endl;
328 std::cout <<
"Create surface for invalid label: ";
329 filter->GenerateAllLabelsOff();
332 if (filter->GetNumberOfOutputs() != 1)
334 std::cout <<
"Number of outputs != 1, [FAILED]" << std::endl;
337 else if (filter->GetOutput()->GetVtkPolyData()->GetNumberOfPoints() != 0)
339 std::cout <<
"PolyData is not empty (" << filter->GetOutput()->GetVtkPolyData()->GetNumberOfPoints()
340 <<
"), [FAILED]" << std::endl;
345 std::cout <<
"[PASSED]" << std::endl;
348 std::cout <<
"[TEST DONE]" << std::endl;
Keeps track of the reference count of an object even if it is destroyed.
int mitkLabeledImageToSurfaceFilterTest(int argc, char *argv[])
bool equals(const mitk::ScalarType &val1, const mitk::ScalarType &val2, mitk::ScalarType epsilon=mitk::eps)
MITKCORE_EXPORT const ScalarType eps
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.