go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkMultiInputImageToImageMetricBase.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkMultiInputImageToImageMetricBase_h
19#define itkMultiInputImageToImageMetricBase_h
20
22#include <vector>
23
25#define itkSetNumberOfMacro(name) \
26 virtual void SetNumberOf##name##s(const unsigned int _arg) \
27 { \
28 if (this->m_NumberOf##name##s != _arg) \
29 { \
30 this->m_##name##Vector.resize(_arg); \
31 this->m_NumberOf##name##s = _arg; \
32 this->Modified(); \
33 } \
34 } // comments for allowing ; after calling the macro
35
36namespace itk
37{
38
48template <class TFixedImage, class TMovingImage>
49class ITK_TEMPLATE_EXPORT MultiInputImageToImageMetricBase
50 : public AdvancedImageToImageMetric<TFixedImage, TMovingImage>
51{
52public:
54
58 using Pointer = SmartPointer<Self>;
59 using ConstPointer = SmartPointer<const Self>;
60
63
65 itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension);
66 itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension);
67
69 using typename Superclass::CoordinateRepresentationType;
70 using typename Superclass::MovingImageType;
71 using typename Superclass::MovingImagePixelType;
72 using typename Superclass::MovingImagePointer;
73 using typename Superclass::MovingImageConstPointer;
74 using typename Superclass::FixedImageType;
75 using typename Superclass::FixedImagePointer;
76 using typename Superclass::FixedImageConstPointer;
77 using typename Superclass::FixedImageRegionType;
78 using typename Superclass::TransformType;
79 using typename Superclass::TransformPointer;
80 using typename Superclass::InputPointType;
81 using typename Superclass::OutputPointType;
82 using typename Superclass::TransformParametersType;
83 using typename Superclass::TransformJacobianType;
84 using typename Superclass::InterpolatorType;
85 using typename Superclass::InterpolatorPointer;
86 using typename Superclass::RealType;
87 using typename Superclass::GradientPixelType;
88 using typename Superclass::GradientImageType;
89 using typename Superclass::GradientImagePointer;
90 using typename Superclass::FixedImageMaskType;
96 using typename Superclass::MeasureType;
97 using typename Superclass::DerivativeType;
98 using typename Superclass::ParametersType;
99
100 using FixedImageInterpolatorType = InterpolateImageFunction<FixedImageType, CoordinateRepresentationType>;
101 using FixedImageInterpolatorPointer = typename FixedImageInterpolatorType::Pointer;
102
104 using FixedImageVectorType = std::vector<FixedImageConstPointer>;
105 using FixedImageMaskVectorType = std::vector<FixedImageMaskConstPointer>;
106 using FixedImageRegionVectorType = std::vector<FixedImageRegionType>;
107 using MovingImageVectorType = std::vector<MovingImageConstPointer>;
108 using MovingImageMaskVectorType = std::vector<MovingImageMaskConstPointer>;
109 using InterpolatorVectorType = std::vector<InterpolatorPointer>;
110 using FixedImageInterpolatorVectorType = std::vector<FixedImageInterpolatorPointer>;
111
115 virtual void
116 SetFixedImage(const FixedImageType * _arg, unsigned int pos);
117
119 void
120 SetFixedImage(const FixedImageType * _arg) override
121 {
122 this->SetFixedImage(_arg, 0);
123 }
124
125
127 virtual const FixedImageType *
128 GetFixedImage(unsigned int pos) const;
129
131 const FixedImageType *
132 GetFixedImage() const override
134 return this->GetFixedImage(0);
140
142 itkGetConstMacro(NumberOfFixedImages, unsigned int);
143
147 virtual void
148 SetFixedImageMask(const FixedImageMaskType * _arg, unsigned int pos);
149
151 void
153 {
154 this->SetFixedImageMask(_arg, 0);
155 }
156
157
159 virtual const FixedImageMaskType *
160 GetFixedImageMask(unsigned int pos) const;
161
163 const FixedImageMaskType *
164 GetFixedImageMask() const override
165 {
166 return this->GetFixedImageMask(0);
167 }
168
169
171 itkSetNumberOfMacro(FixedImageMask);
172
174 itkGetConstMacro(NumberOfFixedImageMasks, unsigned int);
175
179 virtual void
180 SetFixedImageRegion(const FixedImageRegionType _arg, unsigned int pos);
181
183 void
184 SetFixedImageRegion(const FixedImageRegionType _arg) override
185 {
186 this->SetFixedImageRegion(_arg, 0);
187 }
188
189
191 virtual const FixedImageRegionType &
192 GetFixedImageRegion(unsigned int pos) const;
193
195 const FixedImageRegionType &
196 GetFixedImageRegion() const override
197 {
198 return this->GetFixedImageRegion(0);
199 }
200
201
203 itkSetNumberOfMacro(FixedImageRegion);
204
206 itkGetConstMacro(NumberOfFixedImageRegions, unsigned int);
207
211 virtual void
212 SetMovingImage(const MovingImageType * _arg, unsigned int pos);
213
215 void
216 SetMovingImage(const MovingImageType * _arg) override
217 {
218 this->SetMovingImage(_arg, 0);
219 }
220
221
223 virtual const MovingImageType *
224 GetMovingImage(unsigned int pos) const;
225
227 const MovingImageType *
228 GetMovingImage() const override
229 {
230 return this->GetMovingImage(0);
231 }
232
233
236
238 itkGetConstMacro(NumberOfMovingImages, unsigned int);
239
243 virtual void
244 SetMovingImageMask(const MovingImageMaskType * _arg, unsigned int pos);
245
247 void
249 {
250 this->SetMovingImageMask(_arg, 0);
251 }
252
253
255 virtual const MovingImageMaskType *
256 GetMovingImageMask(unsigned int pos) const;
257
259 const MovingImageMaskType *
260 GetMovingImageMask() const override
261 {
262 return this->GetMovingImageMask(0);
263 }
264
265
267 itkSetNumberOfMacro(MovingImageMask);
268
270 itkGetConstMacro(NumberOfMovingImageMasks, unsigned int);
271
277 virtual void
278 SetInterpolator(InterpolatorType * _arg, unsigned int pos);
279
281 void
282 SetInterpolator(InterpolatorType * _arg) override
283 {
284 return this->SetInterpolator(_arg, 0);
285 }
286
287
289 virtual InterpolatorType *
290 GetInterpolator(unsigned int pos) const;
291
293 InterpolatorType *
295 {
296 return this->GetInterpolator(0);
297 }
298
300 const InterpolatorType *
301 GetInterpolator() const override
302 {
303 return this->GetInterpolator(0);
304 }
305
306
308 itkSetNumberOfMacro(Interpolator);
309
311 itkGetConstMacro(NumberOfInterpolators, unsigned int);
312
314 itkGetConstMacro(InterpolatorsAreBSpline, bool);
315
321 virtual void
323
325 virtual void
327 {
328 return this->SetFixedImageInterpolator(_arg, 0);
329 }
330
331
333 virtual FixedImageInterpolatorType *
334 GetFixedImageInterpolator(unsigned int pos) const;
335
339 {
340 return this->GetFixedImageInterpolator(0);
341 }
342
343
345 itkSetNumberOfMacro(FixedImageInterpolator);
346
348 itkGetConstMacro(NumberOfFixedImageInterpolators, unsigned int);
349
353 void
354 Initialize() override;
355
356protected:
359
362
368
371 using BSplineInterpolatorPointer = typename BSplineInterpolatorType::Pointer;
372 using BSplineInterpolatorVectorType = std::vector<BSplineInterpolatorPointer>;
373
375 void
377
381 virtual void
383
387 bool
389 RealType & movingImageValue,
390 MovingImageDerivativeType * gradient) const override;
391
393 bool
394 IsInsideMovingMask(const MovingImagePointType & mappedPoint) const override;
395
397 FixedImageVectorType m_FixedImageVector{};
398 FixedImageMaskVectorType m_FixedImageMaskVector{};
399 FixedImageRegionVectorType m_FixedImageRegionVector{};
400 MovingImageVectorType m_MovingImageVector{};
401 MovingImageMaskVectorType m_MovingImageMaskVector{};
402 InterpolatorVectorType m_InterpolatorVector{};
403 FixedImageInterpolatorVectorType m_FixedImageInterpolatorVector{};
404
405 bool m_InterpolatorsAreBSpline{ false };
406 BSplineInterpolatorVectorType m_BSplineInterpolatorVector{};
407
408private:
409 // Private using-declarations, to avoid `-Woverloaded-virtual` warnings from GCC (GCC 11.4) or clang (macos-12).
410 using Superclass::SetFixedImageMask;
411 using Superclass::SetMovingImageMask;
412
417 void
419
421 FixedImageRegionType m_DummyFixedImageRegion{};
422
423 unsigned int m_NumberOfFixedImages{ 0 };
424 unsigned int m_NumberOfFixedImageMasks{ 0 };
425 unsigned int m_NumberOfFixedImageRegions{ 0 };
426 unsigned int m_NumberOfMovingImages{ 0 };
427 unsigned int m_NumberOfMovingImageMasks{ 0 };
428 unsigned int m_NumberOfInterpolators{ 0 };
429 unsigned int m_NumberOfFixedImageInterpolators{ 0 };
430};
431
432} // end namespace itk
433
434#undef itkSetNumberOfMacro
435
436#ifndef ITK_MANUAL_INSTANTIATION
437# include "itkMultiInputImageToImageMetricBase.hxx"
438#endif
439
440#endif // end #ifndef itkMultiInputImageToImageMetricBase_h
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics.
typename TransformType::OutputPointType MovingImagePointType
typename MovingImageType::IndexType MovingImageIndexType
typename MovingImageType::Pointer MovingImagePointer
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
typename FixedImageType::Pointer FixedImagePointer
SmartPointer< MovingImageMaskType > MovingImageMaskPointer
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
SmartPointer< FixedImageMaskType > FixedImageMaskPointer
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
SmartPointer< const FixedImageMaskType > FixedImageMaskConstPointer
typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
SmartPointer< const MovingImageMaskType > MovingImageMaskConstPointer
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
Implements a metric base class that takes multiple inputs.
typename TransformType::OutputPointType MovingImagePointType
std::vector< MovingImageConstPointer > MovingImageVectorType
typename FixedImageInterpolatorType::Pointer FixedImageInterpolatorPointer
ITK_DISALLOW_COPY_AND_MOVE(MultiInputImageToImageMetricBase)
virtual void SetFixedImageRegion(const FixedImageRegionType _arg, unsigned int pos)
const FixedImageMaskType * GetFixedImageMask() const override
virtual const FixedImageMaskType * GetFixedImageMask(unsigned int pos) const
void SetFixedImageMask(const FixedImageMaskType *_arg) override
virtual void SetFixedImageMask(const FixedImageMaskType *_arg, unsigned int pos)
void SetMovingImage(const MovingImageType *_arg) override
const FixedImageRegionType & GetFixedImageRegion() const override
std::vector< BSplineInterpolatorPointer > BSplineInterpolatorVectorType
virtual const FixedImageRegionType & GetFixedImageRegion(unsigned int pos) const
std::vector< FixedImageInterpolatorPointer > FixedImageInterpolatorVectorType
virtual InterpolatorType * GetInterpolator(unsigned int pos) const
bool EvaluateMovingImageValueAndDerivative(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient) const override
virtual void SetMovingImageMask(const MovingImageMaskType *_arg, unsigned int pos)
void SetInterpolator(InterpolatorType *_arg) override
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
void SetMovingImageMask(const MovingImageMaskType *_arg) override
std::vector< InterpolatorPointer > InterpolatorVectorType
virtual const MovingImageType * GetMovingImage(unsigned int pos) const
std::vector< MovingImageMaskConstPointer > MovingImageMaskVectorType
const MovingImageType * GetMovingImage() const override
virtual const FixedImageType * GetFixedImage(unsigned int pos) const
~MultiInputImageToImageMetricBase() override=default
void SetFixedImage(const FixedImageType *_arg) override
virtual void SetFixedImageInterpolator(FixedImageInterpolatorType *_arg, unsigned int pos)
virtual void SetMovingImage(const MovingImageType *_arg, unsigned int pos)
virtual FixedImageInterpolatorType * GetFixedImageInterpolator(unsigned int pos) const
InterpolateImageFunction< FixedImageType, CoordinateRepresentationType > FixedImageInterpolatorType
const MovingImageMaskType * GetMovingImageMask() const override
std::vector< FixedImageMaskConstPointer > FixedImageMaskVectorType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension)
std::vector< FixedImageConstPointer > FixedImageVectorType
void SetFixedImageRegion(const FixedImageRegionType _arg) override
itkSetNumberOfMacro(FixedImageInterpolator)
virtual const MovingImageMaskType * GetMovingImageMask(unsigned int pos) const
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
virtual FixedImageInterpolatorType * GetFixedImageInterpolator() const
bool IsInsideMovingMask(const MovingImagePointType &mappedPoint) const override
virtual void SetInterpolator(InterpolatorType *_arg, unsigned int pos)
virtual void SetFixedImageInterpolator(FixedImageInterpolatorType *_arg)
std::vector< FixedImageRegionType > FixedImageRegionVectorType
typename BSplineInterpolatorType::Pointer BSplineInterpolatorPointer
void FastEvaluateMovingImageValueAndDerivative(...) const =delete
virtual void SetFixedImage(const FixedImageType *_arg, unsigned int pos)
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
const InterpolatorType * GetInterpolator() const override


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo