18
18
19
19
#include " itkHausdorffDistanceImageFilter.h"
20
20
#include " itkSimpleFilterWatcher.h"
21
+ #include " itkTestingMacros.h"
21
22
22
23
int
23
24
itkHausdorffDistanceImageFilterTest (int , char *[])
24
25
{
25
26
27
+ constexpr unsigned int ImageDimension = 3 ;
28
+
26
29
using Pixel1Type = unsigned int ;
27
30
using Pixel2Type = float ;
28
- enum
29
- {
30
- ImageDimension = 3
31
- };
32
31
33
32
using Image1Type = itk::Image<Pixel1Type, ImageDimension>;
34
33
using Image2Type = itk::Image<Pixel2Type, ImageDimension>;
@@ -80,8 +79,10 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
80
79
++it2;
81
80
}
82
81
83
- int exit_status = EXIT_SUCCESS; // If no failures detected, then EXIT_SUCCESS
84
- // compute the directed Hausdorff distance h(image1,image2)
82
+ // If no failures detected, then EXIT_SUCCESS
83
+ int exit_status = EXIT_SUCCESS;
84
+
85
+ // Compute the directed Hausdorff distance h(image1,image2)
85
86
{
86
87
using FilterType = itk::DirectedHausdorffDistanceImageFilter<Image1Type, Image2Type>;
87
88
FilterType::Pointer filter = FilterType::New ();
@@ -90,9 +91,8 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
90
91
filter->SetInput1 (image1);
91
92
filter->SetInput2 (image2);
92
93
filter->Update ();
93
- filter->Print (std::cout);
94
94
95
- // check results
95
+ // Check results
96
96
const FilterType::RealType trueDistance = 10 * std::sqrt (static_cast <double >(ImageDimension));
97
97
const FilterType::RealType distance = filter->GetDirectedHausdorffDistance ();
98
98
@@ -111,7 +111,7 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
111
111
}
112
112
}
113
113
114
- // compute the directed Hausdorff distance h(image2,image1)
114
+ // Compute the directed Hausdorff distance h(image2,image1)
115
115
{
116
116
using FilterType = itk::DirectedHausdorffDistanceImageFilter<Image2Type, Image1Type>;
117
117
FilterType::Pointer filter = FilterType::New ();
@@ -120,7 +120,7 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
120
120
filter->SetInput2 (image1);
121
121
filter->Update ();
122
122
123
- // check results
123
+ // Check results
124
124
const FilterType::RealType trueDistance = 5 * std::sqrt (static_cast <double >(ImageDimension));
125
125
const FilterType::RealType distance = filter->GetDirectedHausdorffDistance ();
126
126
@@ -140,16 +140,19 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
140
140
}
141
141
}
142
142
143
- // compute the Hausdorff distance H(image1,image2)
143
+ // Compute the Hausdorff distance H(image1,image2)
144
144
{
145
145
using FilterType = itk::HausdorffDistanceImageFilter<Image1Type, Image2Type>;
146
146
FilterType::Pointer filter = FilterType::New ();
147
147
148
+ ITK_EXERCISE_BASIC_OBJECT_METHODS (filter, HausdorffDistanceImageFilter, ImageToImageFilter);
149
+
150
+
148
151
filter->SetInput1 (image1);
149
152
filter->SetInput2 (image2);
150
153
filter->Update ();
151
154
152
- // check results
155
+ // Check results
153
156
const FilterType::RealType trueDistance = 10 * std::sqrt (static_cast <double >(ImageDimension));
154
157
const FilterType::RealType distance = filter->GetHausdorffDistance ();
155
158
@@ -169,7 +172,7 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
169
172
}
170
173
}
171
174
172
- // compute the Hausdorff distance H(image2,image1)
175
+ // Compute the Hausdorff distance H(image2,image1)
173
176
{
174
177
using FilterType = itk::HausdorffDistanceImageFilter<Image2Type, Image1Type>;
175
178
FilterType::Pointer filter = FilterType::New ();
@@ -178,7 +181,7 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
178
181
filter->SetInput2 (image1);
179
182
filter->Update ();
180
183
181
- // check results
184
+ // Check results
182
185
const FilterType::RealType trueDistance = 10 * std::sqrt (static_cast <double >(ImageDimension));
183
186
const FilterType::RealType distance = filter->GetHausdorffDistance ();
184
187
@@ -198,7 +201,7 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
198
201
}
199
202
}
200
203
201
- // compute the Hausdorff distance H(image2,image1)
204
+ // Compute the Hausdorff distance H(image2,image1)
202
205
{
203
206
Image1Type::SpacingType spacing1 = image1->GetSpacing ();
204
207
spacing1[0 ] = spacing1[0 ] / 2 ;
@@ -210,6 +213,7 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
210
213
spacing2[1 ] = spacing2[1 ] / 2 ;
211
214
spacing2[2 ] = spacing2[2 ] / 2 ;
212
215
image2->SetSpacing (spacing2);
216
+
213
217
using FilterType = itk::HausdorffDistanceImageFilter<Image2Type, Image1Type>;
214
218
FilterType::Pointer filter = FilterType::New ();
215
219
@@ -218,7 +222,7 @@ itkHausdorffDistanceImageFilterTest(int, char *[])
218
222
filter->SetUseImageSpacing (true );
219
223
filter->Update ();
220
224
221
- // check results
225
+ // Check results
222
226
const FilterType::RealType trueDistance =
223
227
10 * std::sqrt (spacing1[0 ] * spacing1[0 ] + spacing1[1 ] * spacing1[1 ] + spacing1[2 ] * spacing1[2 ]);
224
228
const FilterType::RealType trueAverageDistance = 4.5 * spacing1[0 ];
0 commit comments