18 #ifndef itkImageToImageMetricv4_h
19 #define itkImageToImageMetricv4_h
168 template <
typename TFixedImage,
169 typename TMovingImage,
170 typename TVirtualImage = TFixedImage,
171 typename TInternalComputationValueType = double,
172 typename TMetricTraits =
173 DefaultImageToImageMetricTraitsv4<TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType>>
176 TMovingImage::ImageDimension,
178 TInternalComputationValueType>
186 TMovingImage::ImageDimension,
188 TInternalComputationValueType>;
201 using typename Superclass::CoordinateRepresentationType;
204 using typename Superclass::ParametersType;
205 using typename Superclass::ParametersValueType;
208 using typename Superclass::GradientSourceEnum;
211 using typename Superclass::DimensionType;
215 using typename Superclass::FixedTransformType;
216 using typename Superclass::FixedTransformPointer;
217 using typename Superclass::FixedInputPointType;
218 using typename Superclass::FixedOutputPointType;
219 using typename Superclass::FixedTransformParametersType;
221 using typename Superclass::MovingTransformType;
222 using typename Superclass::MovingTransformPointer;
223 using typename Superclass::MovingInputPointType;
224 using typename Superclass::MovingOutputPointType;
225 using typename Superclass::MovingTransformParametersType;
227 using typename Superclass::JacobianType;
228 using typename Superclass::FixedTransformJacobianType;
229 using typename Superclass::MovingTransformJacobianType;
252 using typename Superclass::VirtualImagePointer;
253 using typename Superclass::VirtualPixelType;
254 using typename Superclass::VirtualRegionType;
255 using typename Superclass::VirtualSizeType;
256 using typename Superclass::VirtualSpacingType;
258 using typename Superclass::VirtualPointType;
259 using typename Superclass::VirtualDirectionType;
261 using typename Superclass::VirtualIndexType;
262 using typename Superclass::VirtualPointSetType;
263 using typename Superclass::VirtualPointSetPointer;
269 static constexpr DimensionType FixedImageDimension = Superclass::FixedDimension;
270 static constexpr DimensionType MovingImageDimension = Superclass::MovingDimension;
271 static constexpr DimensionType VirtualImageDimension = Superclass::VirtualDimension;
352 using typename Superclass::MeasureType;
355 using typename Superclass::DerivativeType;
360 using typename Superclass::NumberOfParametersType;
366 auto * image = dynamic_cast<FixedImageType *>(const_cast<ObjectType *>(
object));
367 if (image !=
nullptr)
369 this->SetFixedImage(image);
373 itkExceptionMacro(
"Incorrect object type. Should be an image.");
382 auto * image = dynamic_cast<MovingImageType *>(const_cast<ObjectType *>(
object));
383 if (image !=
nullptr)
385 this->SetMovingImage(image);
389 itkExceptionMacro(
"Incorrect object type. Should be an image.");
395 itkSetConstObjectMacro(FixedImage, FixedImageType);
396 itkGetConstObjectMacro(FixedImage, FixedImageType);
399 itkSetConstObjectMacro(MovingImage, MovingImageType);
400 itkGetConstObjectMacro(MovingImage, MovingImageType);
404 itkSetObjectMacro(FixedInterpolator, FixedInterpolatorType);
407 itkGetModifiableObjectMacro(FixedInterpolator, FixedInterpolatorType);
410 itkSetObjectMacro(MovingInterpolator, MovingInterpolatorType);
413 itkGetModifiableObjectMacro(MovingInterpolator, MovingInterpolatorType);
416 itkSetObjectMacro(MovingImageMask, MovingImageMaskType);
417 itkSetConstObjectMacro(MovingImageMask, MovingImageMaskType);
418 itkGetConstObjectMacro(MovingImageMask, MovingImageMaskType);
422 itkSetObjectMacro(FixedImageMask, FixedImageMaskType);
423 itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
424 itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
430 itkSetObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
431 itkSetConstObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
432 itkGetConstObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
436 itkSetObjectMacro(VirtualSampledPointSet, VirtualPointSetType);
437 itkGetConstObjectMacro(VirtualSampledPointSet, VirtualPointSetType);
441 itkSetMacro(UseSampledPointSet,
bool);
442 itkGetConstReferenceMacro(UseSampledPointSet,
bool);
443 itkBooleanMacro(UseSampledPointSet);
448 itkSetMacro(UseVirtualSampledPointSet,
bool);
449 itkGetConstReferenceMacro(UseVirtualSampledPointSet,
bool);
450 itkBooleanMacro(UseVirtualSampledPointSet);
453 #if !defined(ITK_LEGACY_REMOVE)
456 itkLegacyMacro(
virtual void SetUseFixedSampledPointSet(
bool v)) { this->SetUseSampledPointSet(v); }
457 itkLegacyMacro(
virtual bool GetUseFixedSampledPointSet()
const) {
return this->GetUseSampledPointSet(); }
458 itkLegacyMacro(
virtual void UseFixedSampledPointSetOn()) {
return this->UseSampledPointSetOn(); }
459 itkLegacyMacro(
virtual void UseFixedSampledPointSetOff()) {
return this->UseSampledPointSetOff(); }
465 itkSetObjectMacro(FixedImageGradientFilter, FixedImageGradientFilterType);
466 itkGetModifiableObjectMacro(FixedImageGradientFilter, FixedImageGradientFilterType);
467 itkSetObjectMacro(MovingImageGradientFilter, MovingImageGradientFilterType);
468 itkGetModifiableObjectMacro(MovingImageGradientFilter, MovingImageGradientFilterType);
472 itkSetObjectMacro(FixedImageGradientCalculator, FixedImageGradientCalculatorType);
473 itkGetModifiableObjectMacro(FixedImageGradientCalculator, FixedImageGradientCalculatorType);
474 itkSetObjectMacro(MovingImageGradientCalculator, MovingImageGradientCalculatorType);
475 itkGetModifiableObjectMacro(MovingImageGradientCalculator, MovingImageGradientCalculatorType);
480 itkSetMacro(UseFixedImageGradientFilter,
bool);
481 itkGetConstReferenceMacro(UseFixedImageGradientFilter,
bool);
482 itkBooleanMacro(UseFixedImageGradientFilter);
486 itkSetMacro(UseMovingImageGradientFilter,
bool);
487 itkGetConstReferenceMacro(UseMovingImageGradientFilter,
bool);
488 itkBooleanMacro(UseMovingImageGradientFilter);
495 GetNumberOfWorkUnitsUsed()
const;
503 GetMaximumNumberOfWorkUnits()
const;
506 #if !defined(ITK_LEGACY_REMOVE)
512 itkLegacyMacro(
virtual ThreadIdType GetNumberOfThreadsUsed()
const) {
return this->GetNumberOfWorkUnitsUsed(); }
520 itkLegacyMacro(
virtual void SetMaximumNumberOfThreads(
const ThreadIdType count))
522 this->SetMaximumNumberOfWorkUnits(count);
524 itkLegacyMacro(
virtual ThreadIdType GetMaximumNumberOfThreads()
const) {
return this->GetMaximumNumberOfWorkUnits(); }
525 #endif // !ITK_LEGACY_REMOVE
542 itkGetModifiableObjectMacro(FixedImageGradientImage, FixedImageGradientImageType);
545 itkGetModifiableObjectMacro(MovingImageGradientImage, MovingImageGradientImageType);
552 GetNumberOfDomainPoints()
const;
567 itkSetMacro(UseFloatingPointCorrection,
bool);
568 itkGetConstReferenceMacro(UseFloatingPointCorrection,
bool);
569 itkBooleanMacro(UseFloatingPointCorrection);
576 itkSetMacro(FloatingPointCorrectionResolution, DerivativeValueType);
577 itkGetConstMacro(FloatingPointCorrectionResolution, DerivativeValueType);
589 Initialize()
override;
592 GetValue()
const override;
595 GetDerivative(DerivativeType &)
const override;
603 GetValueAndDerivative(MeasureType & value, DerivativeType & derivative)
const override;
608 itkGetConstReferenceMacro(NumberOfSkippedFixedSampledPoints,
SizeValueType);
616 using typename Superclass::MetricCategoryType;
622 return MetricCategoryType::IMAGE_METRIC;
627 using FixedImageGradientInterpolatorType =
656 InitializeForIteration()
const;
688 ComputeFixedImageGradientFilterImage();
694 ComputeMovingImageGradientFilterImage()
const;
703 GetValueAndDerivativeExecute()
const;
708 InitializeDefaultFixedImageGradientFilter();
710 InitializeDefaultMovingImageGradientFilter();
714 itkGetConstMacro(ComputeDerivative,
bool);
727 bool m_UseFixedImageGradientFilter{};
728 bool m_UseMovingImageGradientFilter{};
766 VirtualPointSetPointer m_VirtualSampledPointSet{};
769 bool m_UseSampledPointSet{};
773 bool m_UseVirtualSampledPointSet{};
779 PrintSelf(std::ostream & os,
Indent indent)
const override;
784 MapFixedSampledPointSetToVirtual();
791 mappedFixedPoint = this->m_FixedTransform->TransformPoint(virtualPoint);
794 template <
typename TVirtualPo
int>
802 localVirtualPoint.
CastFrom(virtualPoint);
804 mappedFixedPoint = this->m_FixedTransform->TransformPoint(localVirtualPoint);
807 template <
typename TFixedImagePo
int>
810 TFixedImagePoint & mappedFixedPoint)
const
813 localMappedFixedPoint.
CastFrom(mappedFixedPoint);
814 localMappedFixedPoint = this->m_FixedTransform->TransformPoint(virtualPoint);
815 mappedFixedPoint.
CastFrom(localMappedFixedPoint);
818 template <
typename TVirtualPo
int,
typename TFixedImagePo
int>
825 localVirtualPoint.
CastFrom(virtualPoint);
826 localMappedFixedPoint.
CastFrom(mappedFixedPoint);
828 localMappedFixedPoint = this->m_FixedTransform->TransformPoint(localVirtualPoint);
829 mappedFixedPoint.
CastFrom(localMappedFixedPoint);
834 mutable bool m_HaveMadeGetValueWarning{};
841 bool m_UseFloatingPointCorrection{};
847 mutable bool m_ComputeDerivative{};
851 #ifdef ITK_USE_CONCEPT_CHECKING
856 #endif // ITK_USE_CONCEPT_CHECKING
861 #ifndef ITK_MANUAL_INSTANTIATION
862 # include "itkImageToImageMetricv4.hxx"