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::GradientImageFilterType;
103 using typename Superclass::GradientImageFilterPointer;
104 using typename Superclass::FixedImageMaskType;
105 using typename Superclass::FixedImageMaskPointer;
106 using typename Superclass::MovingImageMaskType;
107 using typename Superclass::MovingImageMaskPointer;
108 using typename Superclass::MeasureType;
109 using typename Superclass::DerivativeType;
110 using typename Superclass::DerivativeValueType;
111 using typename Superclass::ParametersType;
112
114 using typename Superclass::HessianValueType;
115 using typename Superclass::HessianType;
116
133 using SingleValuedCostFunctionType = SingleValuedCostFunction;
134 using SingleValuedCostFunctionPointer = typename SingleValuedCostFunctionType::Pointer;
135
136 using FixedImagePixelType = typename FixedImageType::PixelType;
137 using MovingImageRegionType = typename MovingImageType::RegionType;
138 using MovingImageDerivativeScalesType = FixedArray<double, Self::MovingImageDimension>;
139
141 using FixedPointSetType = PointSet<CoordinateRepresentationType,
142 TFixedImage::ImageDimension,
143 DefaultStaticMeshTraits<CoordinateRepresentationType,
144 TFixedImage::ImageDimension,
145 TFixedImage::ImageDimension,
146 CoordinateRepresentationType,
147 CoordinateRepresentationType,
148 CoordinateRepresentationType>>;
149 using MovingPointSetType = PointSet<CoordinateRepresentationType,
150 TMovingImage::ImageDimension,
151 DefaultStaticMeshTraits<CoordinateRepresentationType,
152 TMovingImage::ImageDimension,
153 TMovingImage::ImageDimension,
154 CoordinateRepresentationType,
155 CoordinateRepresentationType,
156 CoordinateRepresentationType>>;
158
160 using typename Superclass::ThreaderType;
161 using typename Superclass::ThreadInfoType;
162
168 void
169 SetNumberOfMetrics(unsigned int count);
170
172 itkGetConstMacro(NumberOfMetrics, unsigned int);
173
178 void
179 SetMetric(SingleValuedCostFunctionType * metric, unsigned int pos);
180
183 GetMetric(unsigned int count) const;
184
186 void
187 SetMetricWeight(double weight, unsigned int pos);
188
190 double
191 GetMetricWeight(unsigned int pos) const;
192
194 void
195 SetMetricRelativeWeight(double weight, unsigned int pos);
196
198 double
199 GetMetricRelativeWeight(unsigned int pos) const;
200
202 itkSetMacro(UseRelativeWeights, bool);
203 itkGetConstMacro(UseRelativeWeights, bool);
204
210 void
211 SetUseMetric(const bool use, const unsigned int pos);
212
214 void
216
218 bool
219 GetUseMetric(const unsigned int pos) const;
220
222 MeasureType
223 GetMetricValue(unsigned int pos) const;
224
226 const DerivativeType &
227 GetMetricDerivative(unsigned int pos) const;
228
230 double
231 GetMetricDerivativeMagnitude(unsigned int pos) const;
232
234 double
235 GetMetricComputationTime(unsigned int pos) const;
236
242 void
243 SetTransform(TransformType * _arg) override;
244
255 virtual void
256 SetTransform(TransformType * _arg, unsigned int pos);
257
261 virtual const TransformType *
262 GetTransform(unsigned int pos) const;
263
265 const TransformType *
266 GetTransform() const override
267 {
268 return this->GetTransform(0);
269 }
270
271
273 void
274 SetInterpolator(InterpolatorType * _arg) override;
275
277 virtual void
278 SetInterpolator(InterpolatorType * _arg, unsigned int pos);
279
283 virtual const InterpolatorType *
284 GetInterpolator(unsigned int pos) const;
285
287 const InterpolatorType *
288 GetInterpolator() const override
289 {
290 return this->GetInterpolator(0);
291 }
292
293
295 void
296 SetFixedImage(const FixedImageType * _arg) override;
297
299 virtual void
300 SetFixedImage(const FixedImageType * _arg, unsigned int pos);
301
305 virtual const FixedImageType *
306 GetFixedImage(unsigned int pos) const;
307
309 const FixedImageType *
310 GetFixedImage() const override
311 {
312 return this->GetFixedImage(0);
313 }
314
315
317 void
318 SetFixedImageMask(FixedImageMaskType * _arg) override;
319
321 virtual void
322 SetFixedImageMask(FixedImageMaskType * _arg, unsigned int pos);
323
327 virtual const FixedImageMaskType *
328 GetFixedImageMask(unsigned int pos) const;
329
331 const FixedImageMaskType *
332 GetFixedImageMask() const override
333 {
334 return this->GetFixedImageMask(0);
335 }
336
337
339 void
340 SetFixedImageRegion(const FixedImageRegionType _arg) override;
341
343 virtual void
344 SetFixedImageRegion(const FixedImageRegionType _arg, unsigned int pos);
345
349 virtual const FixedImageRegionType &
350 GetFixedImageRegion(unsigned int pos) const;
351
353 const FixedImageRegionType &
354 GetFixedImageRegion() const override
355 {
356 return this->GetFixedImageRegion(0);
357 }
358
359
361 void
362 SetMovingImage(const MovingImageType * _arg) override;
363
365 virtual void
366 SetMovingImage(const MovingImageType * _arg, unsigned int pos);
367
371 virtual const MovingImageType *
372 GetMovingImage(unsigned int pos) const;
373
375 const MovingImageType *
376 GetMovingImage() const override
377 {
378 return this->GetMovingImage(0);
379 }
380
381
383 void
384 SetMovingImageMask(MovingImageMaskType * _arg) override;
385
387 virtual void
388 SetMovingImageMask(MovingImageMaskType * _arg, unsigned int pos);
389
393 virtual const MovingImageMaskType *
394 GetMovingImageMask(unsigned int pos) const;
395
397 const MovingImageMaskType *
398 GetMovingImageMask() const override
399 {
400 return this->GetMovingImageMask(0);
401 }
402
403
407 const SizeValueType &
408 GetNumberOfPixelsCounted() const override;
409
411 void
412 Initialize() override;
413
419 MeasureType
420 GetValue(const ParametersType & parameters) const override;
421
423 void
424 GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override;
425
427 void
428 GetValueAndDerivative(const ParametersType & parameters,
429 MeasureType & value,
430 DerivativeType & derivative) const override;
431
433 void
434 GetSelfHessian(const TransformParametersType & parameters, HessianType & H) const override;
435
439 ModifiedTimeType
440 GetMTime() const override;
441
442protected:
444 ~CombinationImageToImageMetric() override = default;
445 void
446 PrintSelf(std::ostream & os, Indent indent) const override;
447
449 unsigned int m_NumberOfMetrics;
450 std::vector<SingleValuedCostFunctionPointer> m_Metrics;
451 std::vector<double> m_MetricWeights;
452 std::vector<double> m_MetricRelativeWeights;
454 std::vector<bool> m_UseMetric;
455 mutable std::vector<MeasureType> m_MetricValues;
456 mutable std::vector<DerivativeType> m_MetricDerivatives;
457 mutable std::vector<double> m_MetricDerivativesMagnitude;
458 mutable std::vector<double> m_MetricComputationTime;
459
461 FixedImageRegionType m_NullFixedImageRegion;
462 DerivativeType m_NullDerivative;
463
464private:
469 void
471
475 double
476 GetFinalMetricWeight(unsigned int pos) const;
477};
478
479} // end namespace itk
480
481#ifndef ITK_MANUAL_INSTANTIATION
482# include "itkCombinationImageToImageMetric.hxx"
483#endif
484
485#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
typename DerivativeType::ValueType HessianValueType
typename ThreaderType::WorkUnitInfo ThreadInfoType
vnl_sparse_matrix< HessianValueType > HessianType
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
typename SingleValuedCostFunctionType::Pointer SingleValuedCostFunctionPointer
const FixedImageMaskType * GetFixedImageMask() const override
const SizeValueType & GetNumberOfPixelsCounted() const override
void SetFixedImage(const FixedImageType *_arg) override
void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const override
void SetMovingImageMask(MovingImageMaskType *_arg) 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)
typename TransformType::Pointer TransformPointer
const TransformType * GetTransform() const override
typename FixedImageType::PixelType FixedImagePixelType
void PrintSelf(std::ostream &os, Indent indent) const override
void SetFixedImageMask(FixedImageMaskType *_arg) override
PointSet< CoordinateRepresentationType, TMovingImage::ImageDimension, DefaultStaticMeshTraits< CoordinateRepresentationType, TMovingImage::ImageDimension, TMovingImage::ImageDimension, CoordinateRepresentationType, CoordinateRepresentationType, CoordinateRepresentationType > > MovingPointSetType
MeasureType GetValue(const ParametersType &parameters) const override
typename MovingImageType::RegionType MovingImageRegionType
void SetMetric(SingleValuedCostFunctionType *metric, unsigned int pos)
const FixedImageRegionType & GetFixedImageRegion() const override
std::vector< SingleValuedCostFunctionPointer > m_Metrics
virtual void SetMovingImageMask(MovingImageMaskType *_arg, unsigned int pos)
void SetFixedImageRegion(const FixedImageRegionType _arg) override
ModifiedTimeType GetMTime() const override
virtual const MovingImageMaskType * GetMovingImageMask(unsigned int pos) const
double GetMetricDerivativeMagnitude(unsigned int pos) const
PointSet< CoordinateRepresentationType, TFixedImage::ImageDimension, DefaultStaticMeshTraits< CoordinateRepresentationType, TFixedImage::ImageDimension, TFixedImage::ImageDimension, CoordinateRepresentationType, CoordinateRepresentationType, CoordinateRepresentationType > > FixedPointSetType
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 SetFixedImage(const FixedImageType *_arg, unsigned int pos)
void GetValueAndDerivative(const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const override
SingleValuedCostFunctionType * GetMetric(unsigned int count) const
bool GetUseMetric(const unsigned int pos) const
typename Superclass::AdvancedTransformType TransformType
virtual void SetFixedImageMask(FixedImageMaskType *_arg, unsigned int pos)
typename ImageMetricType::Pointer ImageMetricPointer
const InterpolatorType * GetInterpolator() const override
vnl_sparse_matrix< HessianValueType > HessianType
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)
void GetSelfHessian(const TransformParametersType &parameters, HessianType &H) const override
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)
void SetMetricRelativeWeight(double weight, unsigned int pos)


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo