go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkCombinationImageToImageMetric.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 itkCombinationImageToImageMetric_h
19#define itkCombinationImageToImageMetric_h
20
23
24namespace itk
25{
26
58template <class TFixedImage, class TMovingImage>
59class ITK_TEMPLATE_EXPORT CombinationImageToImageMetric : public AdvancedImageToImageMetric<TFixedImage, TMovingImage>
60{
61public:
63
67 using Pointer = SmartPointer<Self>;
68 using ConstPointer = SmartPointer<const Self>;
69
72
74 itkNewMacro(Self);
75
77 itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension);
78 itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension);
79
81 using typename Superclass::CoordinateRepresentationType;
82 using typename Superclass::MovingImageType;
83 using typename Superclass::MovingImagePixelType;
84 // using typename Superclass::MovingImagePointer;
85 using typename Superclass::MovingImageConstPointer;
86 using typename Superclass::FixedImageType;
87 // using typename Superclass::FixedImagePointer;
88 using typename Superclass::FixedImageConstPointer;
89 using typename Superclass::FixedImageRegionType;
91 using TransformPointer = typename TransformType::Pointer;
92 using typename Superclass::InputPointType;
93 using typename Superclass::OutputPointType;
94 using typename Superclass::TransformParametersType;
95 using typename Superclass::TransformJacobianType;
96 using typename Superclass::InterpolatorType;
97 using typename Superclass::InterpolatorPointer;
98 using typename Superclass::RealType;
99 using typename Superclass::GradientPixelType;
100 using typename Superclass::GradientImageType;
101 using typename Superclass::GradientImagePointer;
102 using typename Superclass::FixedImageMaskType;
104 using typename Superclass::MovingImageMaskType;
106 using typename Superclass::MeasureType;
107 using typename Superclass::DerivativeType;
108 using typename Superclass::DerivativeValueType;
109 using typename Superclass::ParametersType;
110
127 using SingleValuedCostFunctionType = SingleValuedCostFunction;
128 using SingleValuedCostFunctionPointer = typename SingleValuedCostFunctionType::Pointer;
129
130 using FixedImagePixelType = typename FixedImageType::PixelType;
131 using MovingImageRegionType = typename MovingImageType::RegionType;
132 using MovingImageDerivativeScalesType = FixedArray<double, Self::MovingImageDimension>;
133
135 using FixedPointSetType = PointSet<CoordinateRepresentationType,
136 TFixedImage::ImageDimension,
137 DefaultStaticMeshTraits<CoordinateRepresentationType,
138 TFixedImage::ImageDimension,
139 TFixedImage::ImageDimension,
140 CoordinateRepresentationType,
141 CoordinateRepresentationType,
142 CoordinateRepresentationType>>;
143 using MovingPointSetType = PointSet<CoordinateRepresentationType,
144 TMovingImage::ImageDimension,
145 DefaultStaticMeshTraits<CoordinateRepresentationType,
146 TMovingImage::ImageDimension,
147 TMovingImage::ImageDimension,
148 CoordinateRepresentationType,
149 CoordinateRepresentationType,
150 CoordinateRepresentationType>>;
152
154 using typename Superclass::ThreadInfoType;
155
161 void
162 SetNumberOfMetrics(unsigned int count);
163
165 itkGetConstMacro(NumberOfMetrics, unsigned int);
166
171 void
172 SetMetric(SingleValuedCostFunctionType * metric, unsigned int pos);
173
176 GetMetric(unsigned int count) const;
177
179 void
180 SetMetricWeight(double weight, unsigned int pos);
181
183 double
184 GetMetricWeight(unsigned int pos) const;
185
187 void
188 SetMetricRelativeWeight(double weight, unsigned int pos);
189
191 double
192 GetMetricRelativeWeight(unsigned int pos) const;
193
195 itkSetMacro(UseRelativeWeights, bool);
196 itkGetConstMacro(UseRelativeWeights, bool);
197
203 void
204 SetUseMetric(const bool use, const unsigned int pos);
205
207 void
209
211 bool
212 GetUseMetric(const unsigned int pos) const;
213
215 MeasureType
216 GetMetricValue(unsigned int pos) const;
217
219 const DerivativeType &
220 GetMetricDerivative(unsigned int pos) const;
221
223 double
224 GetMetricDerivativeMagnitude(unsigned int pos) const;
225
227 double
228 GetMetricComputationTime(unsigned int pos) const;
229
235 void
236 SetTransform(TransformType * _arg) override;
237
248 virtual void
249 SetTransform(TransformType * _arg, unsigned int pos);
250
254 virtual const TransformType *
255 GetTransform(unsigned int pos) const;
256
259 GetTransform() override
260 {
261 const auto metric = dynamic_cast<ImageMetricType *>(this->GetMetric(0));
262 return metric ? metric->GetTransform() : nullptr;
263 }
264
266 const TransformType *
267 GetTransform() const override
268 {
269 return this->GetTransform(0);
270 }
271
272
274 void
275 SetInterpolator(InterpolatorType * _arg) override;
276
278 virtual void
279 SetInterpolator(InterpolatorType * _arg, unsigned int pos);
280
284 virtual const InterpolatorType *
285 GetInterpolator(unsigned int pos) const;
286
288 InterpolatorType *
290 {
291 const auto metric = dynamic_cast<ImageMetricType *>(this->GetMetric(0));
292 return metric ? metric->GetInterpolator() : nullptr;
293 }
294
296 const InterpolatorType *
297 GetInterpolator() const override
298 {
299 return this->GetInterpolator(0);
300 }
301
302
304 void
305 SetFixedImage(const FixedImageType * _arg) override;
306
308 virtual void
309 SetFixedImage(const FixedImageType * _arg, unsigned int pos);
310
314 virtual const FixedImageType *
315 GetFixedImage(unsigned int pos) const;
316
318 const FixedImageType *
319 GetFixedImage() const override
320 {
321 return this->GetFixedImage(0);
322 }
323
324
326 void
327 SetFixedImageMask(const FixedImageMaskType * _arg) override;
328
330 virtual void
331 SetFixedImageMask(const FixedImageMaskType * _arg, unsigned int pos);
332
336 virtual const FixedImageMaskType *
337 GetFixedImageMask(unsigned int pos) const;
338
340 const FixedImageMaskType *
341 GetFixedImageMask() const override
342 {
343 return this->GetFixedImageMask(0);
344 }
345
346
348 void
349 SetFixedImageRegion(const FixedImageRegionType _arg) override;
350
352 virtual void
353 SetFixedImageRegion(const FixedImageRegionType _arg, unsigned int pos);
354
358 virtual const FixedImageRegionType &
359 GetFixedImageRegion(unsigned int pos) const;
360
362 const FixedImageRegionType &
363 GetFixedImageRegion() const override
364 {
365 return this->GetFixedImageRegion(0);
366 }
367
368
370 void
371 SetMovingImage(const MovingImageType * _arg) override;
372
374 virtual void
375 SetMovingImage(const MovingImageType * _arg, unsigned int pos);
376
380 virtual const MovingImageType *
381 GetMovingImage(unsigned int pos) const;
382
384 const MovingImageType *
385 GetMovingImage() const override
386 {
387 return this->GetMovingImage(0);
388 }
389
390
392 void
394
396 virtual void
397 SetMovingImageMask(const MovingImageMaskType * _arg, unsigned int pos);
398
402 virtual const MovingImageMaskType *
403 GetMovingImageMask(unsigned int pos) const;
404
406 const MovingImageMaskType *
407 GetMovingImageMask() const override
408 {
409 return this->GetMovingImageMask(0);
410 }
411
412
416 const SizeValueType &
417 GetNumberOfPixelsCounted() const override;
418
420 void
421 Initialize() override;
422
428 MeasureType
429 GetValue(const ParametersType & parameters) const override;
430
432 void
433 GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override;
434
436 void
437 GetValueAndDerivative(const ParametersType & parameters,
438 MeasureType & value,
439 DerivativeType & derivative) const override;
440
444 ModifiedTimeType
445 GetMTime() const override;
446
447protected:
449 ~CombinationImageToImageMetric() override = default;
450 void
451 PrintSelf(std::ostream & os, Indent indent) const override;
452
454 unsigned int m_NumberOfMetrics{ 0 };
455 std::vector<SingleValuedCostFunctionPointer> m_Metrics{};
456 std::vector<double> m_MetricWeights{};
457 std::vector<double> m_MetricRelativeWeights{};
458 bool m_UseRelativeWeights{ false };
459 std::vector<bool> m_UseMetric{};
460 mutable std::vector<MeasureType> m_MetricValues{};
461 mutable std::vector<DerivativeType> m_MetricDerivatives{};
462 mutable std::vector<double> m_MetricDerivativesMagnitude{};
463 mutable std::vector<double> m_MetricComputationTime{};
464
466 FixedImageRegionType m_NullFixedImageRegion{};
467 DerivativeType m_NullDerivative{};
468
469private:
470 // Private using-declarations, to avoid `-Woverloaded-virtual` warnings from GCC (GCC 11.4) or clang (macos-12).
471 using Superclass::SetFixedImageMask;
472 using Superclass::SetMovingImageMask;
473 using Superclass::SetTransform;
474
479 void
481
485 double
486 GetFinalMetricWeight(unsigned int pos) const;
487};
488
489} // end namespace itk
490
491#ifndef ITK_MANUAL_INSTANTIATION
492# include "itkCombinationImageToImageMetric.hxx"
493#endif
494
495#endif // end #ifndef itkCombinationImageToImageMetric_h
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics.
typename DerivativeType::ValueType DerivativeValueType
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
SmartPointer< MovingImageMaskType > MovingImageMaskPointer
MultiThreaderBase::WorkUnitInfo ThreadInfoType
SmartPointer< FixedImageMaskType > FixedImageMaskPointer
AdvancedTransformType * GetTransform() override
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
Transform maps points, vectors and covariant vectors from an input space to an output space.
virtual const FixedImageRegionType & GetFixedImageRegion(unsigned int pos) const
double GetFinalMetricWeight(unsigned int pos) const
const FixedImageType * GetFixedImage() const override
PointSet< CoordinateRepresentationType, TFixedImage::ImageDimension, DefaultStaticMeshTraits< CoordinateRepresentationType, TFixedImage::ImageDimension, TFixedImage::ImageDimension, CoordinateRepresentationType, CoordinateRepresentationType, CoordinateRepresentationType > > FixedPointSetType
typename SingleValuedCostFunctionType::Pointer SingleValuedCostFunctionPointer
virtual void SetMovingImageMask(const MovingImageMaskType *_arg, unsigned int pos)
const FixedImageMaskType * GetFixedImageMask() const override
const SizeValueType & GetNumberOfPixelsCounted() const override
void SetFixedImage(const FixedImageType *_arg) override
void SetFixedImageMask(const FixedImageMaskType *_arg) override
void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const override
double GetMetricRelativeWeight(unsigned int pos) const
void SetInterpolator(InterpolatorType *_arg) override
virtual const FixedImageType * GetFixedImage(unsigned int pos) const
const MovingImageMaskType * GetMovingImageMask() const override
itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension)
void SetTransform(TransformType *_arg) override
MeasureType GetMetricValue(unsigned int pos) const
double GetMetricWeight(unsigned int pos) const
virtual const MovingImageType * GetMovingImage(unsigned int pos) const
~CombinationImageToImageMetric() override=default
ITK_DISALLOW_COPY_AND_MOVE(CombinationImageToImageMetric)
const TransformType * GetTransform() const override
typename FixedImageType::PixelType FixedImagePixelType
void PrintSelf(std::ostream &os, Indent indent) const override
MeasureType GetValue(const ParametersType &parameters) const override
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
typename MovingImageType::RegionType MovingImageRegionType
void SetMetric(SingleValuedCostFunctionType *metric, unsigned int pos)
const FixedImageRegionType & GetFixedImageRegion() const override
void SetFixedImageRegion(const FixedImageRegionType _arg) override
ModifiedTimeType GetMTime() const override
virtual const MovingImageMaskType * GetMovingImageMask(unsigned int pos) const
double GetMetricDerivativeMagnitude(unsigned int pos) const
void SetUseMetric(const bool use, const unsigned int pos)
virtual void SetTransform(TransformType *_arg, unsigned int pos)
const DerivativeType & GetMetricDerivative(unsigned int pos) const
virtual const InterpolatorType * GetInterpolator(unsigned int pos) const
void SetMetricWeight(double weight, unsigned int pos)
virtual void SetFixedImageMask(const FixedImageMaskType *_arg, unsigned int pos)
PointSet< CoordinateRepresentationType, TMovingImage::ImageDimension, DefaultStaticMeshTraits< CoordinateRepresentationType, TMovingImage::ImageDimension, TMovingImage::ImageDimension, CoordinateRepresentationType, CoordinateRepresentationType, CoordinateRepresentationType > > MovingPointSetType
virtual void SetFixedImage(const FixedImageType *_arg, unsigned int pos)
void GetValueAndDerivative(const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const override
SingleValuedCostFunctionType * GetMetric(unsigned int count) const
void SetMovingImageMask(const MovingImageMaskType *_arg) override
bool GetUseMetric(const unsigned int pos) const
typename Superclass::AdvancedTransformType TransformType
typename ImageMetricType::Pointer ImageMetricPointer
const InterpolatorType * GetInterpolator() const override
void SetMovingImage(const MovingImageType *_arg) override
void SetNumberOfMetrics(unsigned int count)
virtual const FixedImageMaskType * GetFixedImageMask(unsigned int pos) const
virtual const TransformType * GetTransform(unsigned int pos) const
virtual void SetFixedImageRegion(const FixedImageRegionType _arg, unsigned int pos)
void InitializeThreadingParameters() const override
virtual void SetInterpolator(InterpolatorType *_arg, unsigned int pos)
const MovingImageType * GetMovingImage() const override
double GetMetricComputationTime(unsigned int pos) const
virtual void SetMovingImage(const MovingImageType *_arg, unsigned int pos)
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
void SetMetricRelativeWeight(double weight, unsigned int pos)


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