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>;
269 static constexpr
DimensionType FixedImageDimension = Superclass::FixedDimension;
270 static constexpr
DimensionType MovingImageDimension = Superclass::MovingDimension;
271 static constexpr
DimensionType VirtualImageDimension = Superclass::VirtualDimension;
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);
551 return this->m_NumberOfValidPoints;
559 GetNumberOfDomainPoints()
const;
574 itkSetMacro(UseFloatingPointCorrection,
bool);
575 itkGetConstReferenceMacro(UseFloatingPointCorrection,
bool);
576 itkBooleanMacro(UseFloatingPointCorrection);
583 itkSetMacro(FloatingPointCorrectionResolution, DerivativeValueType);
584 itkGetConstMacro(FloatingPointCorrectionResolution, DerivativeValueType);
596 Initialize()
override;
599 GetValue()
const override;
602 GetDerivative(DerivativeType &)
const override;
610 GetValueAndDerivative(MeasureType & value, DerivativeType & derivative)
const override;
615 itkGetConstReferenceMacro(NumberOfSkippedFixedSampledPoints,
SizeValueType);
629 return MetricCategoryType::IMAGE_METRIC;
634 using FixedImageGradientInterpolatorType =
663 InitializeForIteration()
const;
695 ComputeFixedImageGradientFilterImage();
701 ComputeMovingImageGradientFilterImage()
const;
710 GetValueAndDerivativeExecute()
const;
715 InitializeDefaultFixedImageGradientFilter();
717 InitializeDefaultMovingImageGradientFilter();
721 itkGetConstMacro(ComputeDerivative,
bool);
786 PrintSelf(std::ostream & os,
Indent indent)
const override;
791 MapFixedSampledPointSetToVirtual();
796 typename FixedTransformType::OutputPointType & mappedFixedPoint)
const
798 mappedFixedPoint = this->m_FixedTransform->TransformPoint(virtualPoint);
801 template <
typename TVirtualPo
int>
804 typename FixedTransformType::OutputPointType & mappedFixedPoint)
const
806 typename FixedTransformType::OutputPointType localVirtualPoint;
809 localVirtualPoint.CastFrom(virtualPoint);
811 mappedFixedPoint = this->m_FixedTransform->TransformPoint(localVirtualPoint);
814 template <
typename TFixedImagePo
int>
817 TFixedImagePoint & mappedFixedPoint)
const
819 typename FixedTransformType::OutputPointType localMappedFixedPoint;
820 localMappedFixedPoint.CastFrom(mappedFixedPoint);
821 localMappedFixedPoint = this->m_FixedTransform->TransformPoint(virtualPoint);
822 mappedFixedPoint.CastFrom(localMappedFixedPoint);
825 template <
typename TVirtualPo
int,
typename TFixedImagePo
int>
829 typename FixedTransformType::OutputPointType localVirtualPoint;
830 typename FixedTransformType::OutputPointType localMappedFixedPoint;
832 localVirtualPoint.CastFrom(virtualPoint);
833 localMappedFixedPoint.CastFrom(mappedFixedPoint);
835 localMappedFixedPoint = this->m_FixedTransform->TransformPoint(localVirtualPoint);
836 mappedFixedPoint.CastFrom(localMappedFixedPoint);
858 #ifdef ITK_USE_CONCEPT_CHECKING
863 #endif // ITK_USE_CONCEPT_CHECKING
868 #ifndef ITK_MANUAL_INSTANTIATION
869 # include "itkImageToImageMetricv4.hxx"