19
19
*/
20
20
21
21
22
-
23
22
// Software Guide : BeginCommandLineArgs
24
23
// INPUTS: {QB_Suburb.png}
25
24
// INPUTS: {QB_Suburb13x17y.png}
68
67
class CommandIterationUpdate : public itk ::Command
69
68
{
70
69
public:
71
- typedef CommandIterationUpdate Self;
72
- typedef itk::Command Superclass;
70
+ typedef CommandIterationUpdate Self;
71
+ typedef itk::Command Superclass;
73
72
typedef itk::SmartPointer<Self> Pointer;
74
73
itkNewMacro (Self);
75
74
76
75
protected:
77
- CommandIterationUpdate () {}
76
+ CommandIterationUpdate ()
77
+ {
78
+ }
78
79
79
80
public:
80
-
81
81
typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
82
- typedef const OptimizerType * OptimizerPointer;
82
+ typedef const OptimizerType* OptimizerPointer;
83
83
84
- void Execute (itk::Object * caller, const itk::EventObject& event) override
84
+ void Execute (itk::Object* caller, const itk::EventObject& event) override
85
85
{
86
- Execute ((const itk::Object *) caller, event);
86
+ Execute ((const itk::Object*) caller, event);
87
87
}
88
88
89
- void Execute (const itk::Object * object, const itk::EventObject& event) override
89
+ void Execute (const itk::Object* object, const itk::EventObject& event) override
90
90
{
91
- OptimizerPointer optimizer =
92
- dynamic_cast <OptimizerPointer>(object);
91
+ OptimizerPointer optimizer = dynamic_cast <OptimizerPointer>(object);
93
92
94
93
if (!itk::IterationEvent ().CheckEvent (&event))
95
- {
94
+ {
96
95
return ;
97
- }
96
+ }
98
97
99
98
std::cout << optimizer->GetCurrentIteration () << " = " ;
100
99
std::cout << optimizer->GetValue () << " : " ;
101
100
std::cout << optimizer->GetCurrentPosition () << std::endl;
102
101
}
103
-
104
102
};
105
103
106
- int main (int argc, char * argv[])
104
+ int main (int argc, char * argv[])
107
105
{
108
106
if (argc < 4 )
109
- {
107
+ {
110
108
std::cerr << " Missing Parameters " << std::endl;
111
109
std::cerr << " Usage: " << argv[0 ];
112
110
std::cerr << " fixedImageFile movingImageFile " ;
113
111
std::cerr << " outputImagefile [differenceImageAfter]" ;
114
112
std::cerr << " [differenceImageBefore]" << std::endl;
115
113
return 1 ;
116
- }
114
+ }
117
115
118
116
// Software Guide : BeginLatex
119
117
//
@@ -125,7 +123,7 @@ int main(int argc, char *argv[])
125
123
126
124
// Software Guide : BeginCodeSnippet
127
125
const unsigned int Dimension = 2 ;
128
- typedef float PixelType;
126
+ typedef float PixelType;
129
127
// Software Guide : EndCodeSnippet
130
128
131
129
// Software Guide : BeginLatex
@@ -170,9 +168,7 @@ int main(int argc, char *argv[])
170
168
// Software Guide : EndLatex
171
169
172
170
// Software Guide : BeginCodeSnippet
173
- typedef itk::MeanSquaresImageToImageMetric<
174
- FixedImageType,
175
- MovingImageType> MetricType;
171
+ typedef itk::MeanSquaresImageToImageMetric<FixedImageType, MovingImageType> MetricType;
176
172
// Software Guide : EndCodeSnippet
177
173
178
174
// Software Guide : BeginLatex
@@ -183,9 +179,7 @@ int main(int argc, char *argv[])
183
179
// Software Guide : EndLatex
184
180
185
181
// Software Guide : BeginCodeSnippet
186
- typedef itk::LinearInterpolateImageFunction<
187
- MovingImageType,
188
- double > InterpolatorType;
182
+ typedef itk::LinearInterpolateImageFunction<MovingImageType, double > InterpolatorType;
189
183
// Software Guide : EndCodeSnippet
190
184
191
185
// Software Guide : BeginLatex
@@ -197,9 +191,7 @@ int main(int argc, char *argv[])
197
191
// Software Guide : EndLatex
198
192
199
193
// Software Guide : BeginCodeSnippet
200
- typedef itk::ImageRegistrationMethod<
201
- FixedImageType,
202
- MovingImageType> RegistrationType;
194
+ typedef itk::ImageRegistrationMethod<FixedImageType, MovingImageType> RegistrationType;
203
195
// Software Guide : EndCodeSnippet
204
196
205
197
// Software Guide : BeginLatex
@@ -211,11 +203,11 @@ int main(int argc, char *argv[])
211
203
// Software Guide : EndLatex
212
204
213
205
// Software Guide : BeginCodeSnippet
214
- MetricType::Pointer metric = MetricType::New ();
215
- TransformType::Pointer transform = TransformType::New ();
216
- OptimizerType::Pointer optimizer = OptimizerType::New ();
217
- InterpolatorType::Pointer interpolator = InterpolatorType::New ();
218
- RegistrationType::Pointer registration = RegistrationType::New ();
206
+ MetricType::Pointer metric = MetricType::New ();
207
+ TransformType::Pointer transform = TransformType::New ();
208
+ OptimizerType::Pointer optimizer = OptimizerType::New ();
209
+ InterpolatorType::Pointer interpolator = InterpolatorType::New ();
210
+ RegistrationType::Pointer registration = RegistrationType::New ();
219
211
// Software Guide : EndCodeSnippet
220
212
221
213
// Software Guide : BeginLatex
@@ -239,8 +231,8 @@ int main(int argc, char *argv[])
239
231
240
232
typedef otb::ImageFileReader<FixedImageType> FixedImageReaderType;
241
233
typedef otb::ImageFileReader<MovingImageType> MovingImageReaderType;
242
- FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New ();
243
- MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New ();
234
+ FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New ();
235
+ MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New ();
244
236
245
237
fixedImageReader->SetFileName (argv[1 ]);
246
238
movingImageReader->SetFileName (argv[2 ]);
@@ -255,11 +247,9 @@ int main(int argc, char *argv[])
255
247
// Software Guide : EndLatex
256
248
257
249
// Software Guide : BeginCodeSnippet
258
- typedef itk::MeanImageFilter<
259
- FixedImageType, FixedImageType> FixedFilterType;
250
+ typedef itk::MeanImageFilter<FixedImageType, FixedImageType> FixedFilterType;
260
251
261
- typedef itk::MeanImageFilter<
262
- MovingImageType, MovingImageType> MovingFilterType;
252
+ typedef itk::MeanImageFilter<MovingImageType, MovingImageType> MovingFilterType;
263
253
264
254
FixedFilterType::Pointer fixedFilter = FixedFilterType::New ();
265
255
MovingFilterType::Pointer movingFilter = MovingFilterType::New ();
@@ -313,8 +303,7 @@ int main(int argc, char *argv[])
313
303
314
304
// Software Guide : BeginCodeSnippet
315
305
fixedFilter->Update ();
316
- registration->SetFixedImageRegion (
317
- fixedFilter->GetOutput ()->GetBufferedRegion ());
306
+ registration->SetFixedImageRegion (fixedFilter->GetOutput ()->GetBufferedRegion ());
318
307
// Software Guide : EndCodeSnippet
319
308
320
309
// Software Guide : BeginLatex
@@ -336,10 +325,10 @@ int main(int argc, char *argv[])
336
325
337
326
// Software Guide : BeginCodeSnippet
338
327
typedef RegistrationType::ParametersType ParametersType;
339
- ParametersType initialParameters (transform->GetNumberOfParameters ());
328
+ ParametersType initialParameters (transform->GetNumberOfParameters ());
340
329
341
- initialParameters[0 ] = 0.0 ; // Initial offset in mm along X
342
- initialParameters[1 ] = 0.0 ; // Initial offset in mm along Y
330
+ initialParameters[0 ] = 0.0 ; // Initial offset in mm along X
331
+ initialParameters[1 ] = 0.0 ; // Initial offset in mm along Y
343
332
344
333
registration->SetInitialTransformParameters (initialParameters);
345
334
// Software Guide : EndCodeSnippet
@@ -412,15 +401,15 @@ int main(int argc, char *argv[])
412
401
413
402
// Software Guide : BeginCodeSnippet
414
403
try
415
- {
404
+ {
416
405
registration->Update ();
417
- }
406
+ }
418
407
catch (itk::ExceptionObject& err)
419
- {
408
+ {
420
409
std::cerr << " ExceptionObject caught !" << std::endl;
421
410
std::cerr << err << std::endl;
422
411
return -1 ;
423
- }
412
+ }
424
413
// Software Guide : EndCodeSnippet
425
414
426
415
// Software Guide : BeginLatex
@@ -488,10 +477,10 @@ int main(int argc, char *argv[])
488
477
// Print out results
489
478
//
490
479
std::cout << " Result = " << std::endl;
491
- std::cout << " Translation X = " << TranslationAlongX << std::endl;
492
- std::cout << " Translation Y = " << TranslationAlongY << std::endl;
480
+ std::cout << " Translation X = " << TranslationAlongX << std::endl;
481
+ std::cout << " Translation Y = " << TranslationAlongY << std::endl;
493
482
std::cout << " Iterations = " << numberOfIterations << std::endl;
494
- std::cout << " Metric value = " << bestValue << std::endl;
483
+ std::cout << " Metric value = " << bestValue << std::endl;
495
484
496
485
// Software Guide : BeginLatex
497
486
//
@@ -542,9 +531,7 @@ int main(int argc, char *argv[])
542
531
// Software Guide : EndLatex
543
532
544
533
// Software Guide : BeginCodeSnippet
545
- typedef itk::ResampleImageFilter<
546
- MovingImageType,
547
- FixedImageType> ResampleFilterType;
534
+ typedef itk::ResampleImageFilter<MovingImageType, FixedImageType> ResampleFilterType;
548
535
// Software Guide : EndCodeSnippet
549
536
550
537
// Software Guide : BeginLatex
@@ -624,11 +611,10 @@ int main(int argc, char *argv[])
624
611
// Software Guide : EndLatex
625
612
626
613
// Software Guide : BeginCodeSnippet
627
- typedef unsigned char OutputPixelType;
628
- typedef otb::Image<OutputPixelType, Dimension> OutputImageType;
629
- typedef itk::CastImageFilter<FixedImageType,
630
- OutputImageType> CastFilterType;
631
- typedef otb::ImageFileWriter<OutputImageType> WriterType;
614
+ typedef unsigned char OutputPixelType;
615
+ typedef otb::Image<OutputPixelType, Dimension> OutputImageType;
616
+ typedef itk::CastImageFilter<FixedImageType, OutputImageType> CastFilterType;
617
+ typedef otb::ImageFileWriter<OutputImageType> WriterType;
632
618
// Software Guide : EndCodeSnippet
633
619
634
620
// Software Guide : BeginLatex
@@ -639,8 +625,8 @@ int main(int argc, char *argv[])
639
625
// Software Guide : EndLatex
640
626
641
627
// Software Guide : BeginCodeSnippet
642
- WriterType::Pointer writer = WriterType::New ();
643
- CastFilterType::Pointer caster = CastFilterType::New ();
628
+ WriterType::Pointer writer = WriterType::New ();
629
+ CastFilterType::Pointer caster = CastFilterType::New ();
644
630
// Software Guide : EndCodeSnippet
645
631
646
632
writer->SetFileName (argv[3 ]);
@@ -680,10 +666,7 @@ int main(int argc, char *argv[])
680
666
// Software Guide : EndLatex
681
667
682
668
// Software Guide : BeginCodeSnippet
683
- typedef itk::SubtractImageFilter<
684
- FixedImageType,
685
- FixedImageType,
686
- FixedImageType> DifferenceFilterType;
669
+ typedef itk::SubtractImageFilter<FixedImageType, FixedImageType, FixedImageType> DifferenceFilterType;
687
670
688
671
DifferenceFilterType::Pointer difference = DifferenceFilterType::New ();
689
672
@@ -715,9 +698,7 @@ int main(int argc, char *argv[])
715
698
// Software Guide : EndLatex
716
699
717
700
// Software Guide : BeginCodeSnippet
718
- typedef itk::RescaleIntensityImageFilter<
719
- FixedImageType,
720
- OutputImageType> RescalerType;
701
+ typedef itk::RescaleIntensityImageFilter<FixedImageType, OutputImageType> RescalerType;
721
702
722
703
RescalerType::Pointer intensityRescaler = RescalerType::New ();
723
704
@@ -740,10 +721,10 @@ int main(int argc, char *argv[])
740
721
// Software Guide : EndCodeSnippet
741
722
742
723
if (argc > 4 )
743
- {
724
+ {
744
725
writer2->SetFileName (argv[4 ]);
745
726
writer2->Update ();
746
- }
727
+ }
747
728
748
729
// Software Guide : BeginLatex
749
730
//
@@ -765,10 +746,10 @@ int main(int argc, char *argv[])
765
746
// Software Guide : EndCodeSnippet
766
747
767
748
if (argc > 5 )
768
- {
749
+ {
769
750
writer2->SetFileName (argv[5 ]);
770
751
writer2->Update ();
771
- }
752
+ }
772
753
773
754
// Software Guide : BeginLatex
774
755
//
0 commit comments