VelocityToDisplacementFieldSS.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_VelocityToDisplacementFieldSS_H
21 #define MIRTK_VelocityToDisplacementFieldSS_H
22 
23 #include "mirtk/VelocityToDisplacementField.h"
24 #include "mirtk/GenericImage.h"
25 
26 
27 namespace mirtk {
28 
29 
30 // Vector field interpolator
31 class InterpolateImageFunction;
32 
33 
34 /**
35  * Computes a displacement field from a stationary velocity field.
36  *
37  * This class implements an image filter which computes the exponential map
38  * of a stationary velocity field using the scaling and squaring method.
39  * The result is a diffeomorphic displacement field.
40  */
41 template <class TVoxel>
43 {
44  mirtkInPlaceImageFilterMacro(VelocityToDisplacementFieldSS, TVoxel);
45 
46  // ---------------------------------------------------------------------------
47  // Attributes
48 
49  /// Number of squaring steps
50  mirtkPublicAttributeMacro(int, NumberOfSquaringSteps);
51 
52  /// Whether to upsample the input vector field before
53  mirtkPublicAttributeMacro(bool, Upsample);
54 
55  /// Whether to use a Gaussian pyramid downsampler when downsampling the
56  /// previously upsample vector field to obey Shannon's sampling theorem.
57  /// Otherwise a simple interpolation without smoothing kernel is used.
58  mirtkPublicAttributeMacro(bool, SmoothBeforeDownsampling);
59 
60  /// Maximum velocity after scaling
61  ///
62  /// Set to zero in order to scale velocities by exactly pow(2.0, _NumberOfSquaringSteps).
63  /// Otherwise, the number of squaring steps is increased in order to ensure that
64  /// the maximum velocity in each dimension is less or equal the specified value.
65  mirtkPublicAttributeMacro(VoxelType, MaxScaledVelocity);
66 
67  /// External memory that can be used for intermedate displacement field
68  mirtkPublicAggregateMacro(ImageType, ExternalCache);
69 
70  /// Intermediate displacement field
71  mirtkAggregateMacro(ImageType, Displacement);
72 
73  /// Interpolator of intermediate displacement field
74  mirtkAggregateMacro(InterpolateImageFunction, Interpolator);
75 
76  // ---------------------------------------------------------------------------
77  // Construction/Destruction
78 
79 public:
80 
81  /// Constructor
83 
84  /// Destructor
86 
87  // ---------------------------------------------------------------------------
88  // Execution
89 
90  /// Compute output = log(input)
91  virtual void Run();
92 
93 protected:
94 
95  /// Initialize filter
96  virtual void Initialize();
97 
98  /// Finalize filter
99  virtual void Finalize();
100 
101 };
102 
103 
104 } // namespace mirtk
105 
106 #endif // MIRTK_VelocityToDisplacementFieldSS_H
virtual ~VelocityToDisplacementFieldSS()
Destructor.
virtual void Initialize()
Initialize filter.
virtual void Finalize()
Finalize filter.
Definition: IOConfig.h:41
TVoxel VoxelType
Input/output image voxel type.
Definition: ImageToImage.h:48
virtual void Run()
Compute output = log(input)