-
Notifications
You must be signed in to change notification settings - Fork 20
/
itkBlockMatchingMultiResolutionImageRegistrationMethod.h
258 lines (204 loc) · 9.25 KB
/
itkBlockMatchingMultiResolutionImageRegistrationMethod.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkBlockMatchingMultiResolutionImageRegistrationMethod_h
#define itkBlockMatchingMultiResolutionImageRegistrationMethod_h
#include "itkImageSource.h"
#include "itkMultiResolutionPyramidImageFilter.h"
#include "itkBlockMatchingImageRegistrationMethod.h"
#include "itkBlockMatchingMultiResolutionBlockRadiusCalculator.h"
#include "itkBlockMatchingMultiResolutionSearchRegionImageSource.h"
namespace itk
{
namespace BlockMatching
{
/** \class MultiResolutionImageRegistrationMethod
*
* \brief Base class for multi-resolution image registration methods in the
* BlockMatching set of tools.
*
* Before each resolution level an IterationEvent is invoked providing an
* opportunity for a user interface to change any of the components,
* change component parameters, or stop the registration.
*
* The SetNumberOfLevels() or SetSchedule() is used to set up the
* MultiResolutionPyramidImageFilter.
*
* \sa ImageRegistrationMethod
*
* \ingroup RegistrationFilters
* \ingroup Ultrasound
* */
template <typename TFixedImage,
typename TMovingImage,
typename TMetricImage,
typename TDisplacementImage,
typename TCoordRep>
class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageSource<TDisplacementImage>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageRegistrationMethod);
/** ImageDimension enumeration. */
itkStaticConstMacro(ImageDimension, unsigned int, TDisplacementImage::ImageDimension);
/** Type of the fixed image. */
using FixedImageType = TFixedImage;
using FixedRegionType = typename FixedImageType::RegionType;
using FixedImagePointer = typename FixedImageType::Pointer;
/** Type of the radius used to characterized the fixed image block. */
using RadiusType = typename FixedImageType::SizeType;
/** Type of the moving image. */
using MovingImageType = TMovingImage;
using MovingRegionType = typename MovingImageType::RegionType;
using MovingImagePointer = typename MovingImageType::Pointer;
/** Type of the metric image. */
using MetricImageType = TMetricImage;
/** Type of the displacement image. */
using DisplacementImageType = TDisplacementImage;
using RegionType = typename DisplacementImageType::RegionType;
using IndexType = typename RegionType::IndexType;
using SizeType = typename RegionType::SizeType;
using SpacingType = typename DisplacementImageType::SpacingType;
using DirectionType = typename DisplacementImageType::DirectionType;
using OriginType = typename DisplacementImageType::PointType;
/** Type of the search region image. */
using SearchRegionImageType = Image<typename MovingImageType::RegionType, ImageDimension>;
/** Standard class type alias. */
using Self = MultiResolutionImageRegistrationMethod;
using Superclass = ImageSource<TDisplacementImage>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(MultiResolutionImageRegistrationMethod, ImageSource);
/** Type of the Fixed image multiresolution pyramid. */
using FixedImagePyramidType = MultiResolutionPyramidImageFilter<FixedImageType, FixedImageType>;
using FixedImagePyramidPointer = typename FixedImagePyramidType::Pointer;
/** Type of pyramid schedule type */
using ScheduleType = typename FixedImagePyramidType::ScheduleType;
/** Type of the moving image multiresolution pyramid. */
using MovingImagePyramidType = MultiResolutionPyramidImageFilter<MovingImageType, MovingImageType>;
using MovingImagePyramidPointer = typename MovingImagePyramidType::Pointer;
/** Type of the registration method used at every level. */
using ImageRegistrationMethodType = typename BlockMatching::
ImageRegistrationMethod<TFixedImage, TMovingImage, TMetricImage, TDisplacementImage, TCoordRep>;
using ImageRegistrationMethodPointer = typename ImageRegistrationMethodType::Pointer;
/** Type of the class to calculate the fixed image matching kernel block
* radius at every level. */
using BlockRadiusCalculatorType = MultiResolutionBlockRadiusCalculator<TFixedImage>;
using BlockRadiusCalculatorPointer = typename BlockRadiusCalculatorType::Pointer;
using SearchRegionImageSourceType =
typename BlockMatching::MultiResolutionSearchRegionImageSource<TFixedImage, TMovingImage, TDisplacementImage>;
using SearchRegionImageSourcePointer = typename SearchRegionImageSourceType::Pointer;
/** Method to stop the registration after registering a level. */
void
StopRegistration();
/** Set/Get the Fixed image. */
itkSetObjectMacro(FixedImage, FixedImageType);
itkGetConstObjectMacro(FixedImage, FixedImageType);
/** Set/Get the Moving image. */
itkSetObjectMacro(MovingImage, MovingImageType);
itkGetConstObjectMacro(MovingImage, MovingImageType);
/** Set/Get the Fixed image pyramid. */
itkSetObjectMacro(FixedImagePyramid, FixedImagePyramidType);
itkGetConstObjectMacro(FixedImagePyramid, FixedImagePyramidType);
/** Set/Get the Moving image pyramid. */
itkSetObjectMacro(MovingImagePyramid, MovingImagePyramidType);
itkGetConstObjectMacro(MovingImagePyramid, MovingImagePyramidType);
/** Set/Get the schedules . */
void
SetSchedules(const ScheduleType & fixedSchedule, const ScheduleType & movingSchedule);
itkGetConstMacro(FixedImagePyramidSchedule, ScheduleType);
itkGetConstMacro(MovingImagePyramidSchedule, ScheduleType);
/** Set/Get the number of multi-resolution levels. */
void
SetNumberOfLevels(unsigned long numberOfLevels);
itkGetConstMacro(NumberOfLevels, unsigned long);
/** Get the current resolution level being processed. */
itkGetConstMacro(CurrentLevel, unsigned long);
/** Method to return the latest modified time of this object or
* any of its cached ivars */
ModifiedTimeType
GetMTime() const override;
/** BlockMatching::ImageRegistrationMethod used to register each image at
* every level. */
itkSetObjectMacro(ImageRegistrationMethod, ImageRegistrationMethodType);
itkGetModifiableObjectMacro(ImageRegistrationMethod, ImageRegistrationMethodType);
/** Set the object used to generate the block radii in the fixed image at
* every level. */
itkSetObjectMacro(BlockRadiusCalculator, BlockRadiusCalculatorType);
itkGetConstObjectMacro(BlockRadiusCalculator, BlockRadiusCalculatorType);
/** Set the object used to generate the search regions. */
itkSetObjectMacro(SearchRegionImageSource, SearchRegionImageSourceType);
itkGetConstObjectMacro(SearchRegionImageSource, SearchRegionImageSourceType);
protected:
MultiResolutionImageRegistrationMethod();
~MultiResolutionImageRegistrationMethod() override = default;
/** The size and spacing of the search region image at the lowest level is
* used to generate the information for the output image. */
void
GenerateOutputInformation() override;
/** Generates the entire displacement image. */
void
EnlargeOutputRequestedRegion(DataObject * itkNotUsed(data)) override
{
TDisplacementImage * output = this->GetOutput(0);
output->SetRequestedRegionToLargestPossibleRegion();
}
/** Method invoked by the pipeline in order to trigger the computation of
* the registration. */
void
GenerateData() override;
/** Initialize by setting the interconnects between the components.
This method is executed at every level of the pyramid with the
values corresponding to this resolution
*/
void
Initialize();
/** Create the image pyramids. */
void
PreparePyramids();
/** Set up the fixed block radius calculator. */
void
PrepareBlockRadiusCalculator();
/** Set up the search region image calculator. */
void
PrepareSearchRegionImageSource();
/** Set the current level to be processed */
itkSetMacro(CurrentLevel, unsigned long);
FixedImagePointer m_FixedImage;
MovingImagePointer m_MovingImage;
FixedImagePyramidPointer m_FixedImagePyramid;
MovingImagePyramidPointer m_MovingImagePyramid;
unsigned long m_NumberOfLevels;
unsigned long m_CurrentLevel;
bool m_Stop;
ScheduleType m_FixedImagePyramidSchedule;
ScheduleType m_MovingImagePyramidSchedule;
bool m_ScheduleSpecified;
bool m_NumberOfLevelsSpecified;
ImageRegistrationMethodPointer m_ImageRegistrationMethod;
BlockRadiusCalculatorPointer m_BlockRadiusCalculator;
SearchRegionImageSourcePointer m_SearchRegionImageSource;
private:
};
} // end namespace BlockMatching
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
# include "itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx"
#endif
#endif