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 #ifndef ITK_FUTURE_LEGACY_REMOVE
418 SetMovingImageMask(MovingImageMaskType *
const arg)
420 const auto *
const constArg = arg;
422 this->SetMovingImageMask(constArg);
425 itkSetConstObjectMacro(MovingImageMask, MovingImageMaskType);
426 itkGetConstObjectMacro(MovingImageMask, MovingImageMaskType);
430 #ifndef ITK_FUTURE_LEGACY_REMOVE
432 SetFixedImageMask(FixedImageMaskType *
const arg)
434 const auto *
const constArg = arg;
436 this->SetFixedImageMask(constArg);
439 itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
440 itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
446 #ifndef ITK_FUTURE_LEGACY_REMOVE
448 SetFixedSampledPointSet(FixedSampledPointSetType *
const arg)
450 const auto *
const constArg = arg;
452 this->SetFixedSampledPointSet(constArg);
455 itkSetConstObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
456 itkGetConstObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
460 itkSetObjectMacro(VirtualSampledPointSet, VirtualPointSetType);
461 itkGetConstObjectMacro(VirtualSampledPointSet, VirtualPointSetType);
465 itkSetMacro(UseSampledPointSet,
bool);
466 itkGetConstReferenceMacro(UseSampledPointSet,
bool);
467 itkBooleanMacro(UseSampledPointSet);
472 itkSetMacro(UseVirtualSampledPointSet,
bool);
473 itkGetConstReferenceMacro(UseVirtualSampledPointSet,
bool);
474 itkBooleanMacro(UseVirtualSampledPointSet);
477 #if !defined(ITK_LEGACY_REMOVE)
480 itkLegacyMacro(
virtual void SetUseFixedSampledPointSet(
bool v)) { this->SetUseSampledPointSet(v); }
481 itkLegacyMacro(
virtual bool GetUseFixedSampledPointSet()
const) {
return this->GetUseSampledPointSet(); }
482 itkLegacyMacro(
virtual void UseFixedSampledPointSetOn()) {
return this->UseSampledPointSetOn(); }
483 itkLegacyMacro(
virtual void UseFixedSampledPointSetOff()) {
return this->UseSampledPointSetOff(); }
489 itkSetObjectMacro(FixedImageGradientFilter, FixedImageGradientFilterType);
490 itkGetModifiableObjectMacro(FixedImageGradientFilter, FixedImageGradientFilterType);
491 itkSetObjectMacro(MovingImageGradientFilter, MovingImageGradientFilterType);
492 itkGetModifiableObjectMacro(MovingImageGradientFilter, MovingImageGradientFilterType);
496 itkSetObjectMacro(FixedImageGradientCalculator, FixedImageGradientCalculatorType);
497 itkGetModifiableObjectMacro(FixedImageGradientCalculator, FixedImageGradientCalculatorType);
498 itkSetObjectMacro(MovingImageGradientCalculator, MovingImageGradientCalculatorType);
499 itkGetModifiableObjectMacro(MovingImageGradientCalculator, MovingImageGradientCalculatorType);
504 itkSetMacro(UseFixedImageGradientFilter,
bool);
505 itkGetConstReferenceMacro(UseFixedImageGradientFilter,
bool);
506 itkBooleanMacro(UseFixedImageGradientFilter);
510 itkSetMacro(UseMovingImageGradientFilter,
bool);
511 itkGetConstReferenceMacro(UseMovingImageGradientFilter,
bool);
512 itkBooleanMacro(UseMovingImageGradientFilter);
519 GetNumberOfWorkUnitsUsed()
const;
527 GetMaximumNumberOfWorkUnits()
const;
530 #if !defined(ITK_LEGACY_REMOVE)
536 itkLegacyMacro(
virtual ThreadIdType GetNumberOfThreadsUsed()
const) {
return this->GetNumberOfWorkUnitsUsed(); }
544 itkLegacyMacro(
virtual void SetMaximumNumberOfThreads(
const ThreadIdType count))
546 this->SetMaximumNumberOfWorkUnits(count);
548 itkLegacyMacro(
virtual ThreadIdType GetMaximumNumberOfThreads()
const) {
return this->GetMaximumNumberOfWorkUnits(); }
549 #endif // !ITK_LEGACY_REMOVE
566 itkGetModifiableObjectMacro(FixedImageGradientImage, FixedImageGradientImageType);
569 itkGetModifiableObjectMacro(MovingImageGradientImage, MovingImageGradientImageType);
576 GetNumberOfDomainPoints()
const;
591 itkSetMacro(UseFloatingPointCorrection,
bool);
592 itkGetConstReferenceMacro(UseFloatingPointCorrection,
bool);
593 itkBooleanMacro(UseFloatingPointCorrection);
600 itkSetMacro(FloatingPointCorrectionResolution, DerivativeValueType);
601 itkGetConstMacro(FloatingPointCorrectionResolution, DerivativeValueType);
613 Initialize()
override;
616 GetValue()
const override;
619 GetDerivative(DerivativeType &)
const override;
627 GetValueAndDerivative(MeasureType & value, DerivativeType & derivative)
const override;
632 itkGetConstReferenceMacro(NumberOfSkippedFixedSampledPoints,
SizeValueType);
640 using typename Superclass::MetricCategoryType;
646 return MetricCategoryType::IMAGE_METRIC;
651 using FixedImageGradientInterpolatorType =
680 InitializeForIteration()
const;
712 ComputeFixedImageGradientFilterImage();
718 ComputeMovingImageGradientFilterImage()
const;
727 GetValueAndDerivativeExecute()
const;
732 InitializeDefaultFixedImageGradientFilter();
734 InitializeDefaultMovingImageGradientFilter();
738 itkGetConstMacro(ComputeDerivative,
bool);
751 bool m_UseFixedImageGradientFilter{};
752 bool m_UseMovingImageGradientFilter{};
790 VirtualPointSetPointer m_VirtualSampledPointSet{};
793 bool m_UseSampledPointSet{};
797 bool m_UseVirtualSampledPointSet{};
803 PrintSelf(std::ostream & os,
Indent indent)
const override;
808 MapFixedSampledPointSetToVirtual();
815 mappedFixedPoint = this->m_FixedTransform->TransformPoint(virtualPoint);
818 template <
typename TVirtualPo
int>
826 localVirtualPoint.
CastFrom(virtualPoint);
828 mappedFixedPoint = this->m_FixedTransform->TransformPoint(localVirtualPoint);
831 template <
typename TFixedImagePo
int>
834 TFixedImagePoint & mappedFixedPoint)
const
837 localMappedFixedPoint.
CastFrom(mappedFixedPoint);
838 localMappedFixedPoint = this->m_FixedTransform->TransformPoint(virtualPoint);
839 mappedFixedPoint.
CastFrom(localMappedFixedPoint);
842 template <
typename TVirtualPo
int,
typename TFixedImagePo
int>
849 localVirtualPoint.
CastFrom(virtualPoint);
850 localMappedFixedPoint.
CastFrom(mappedFixedPoint);
852 localMappedFixedPoint = this->m_FixedTransform->TransformPoint(localVirtualPoint);
853 mappedFixedPoint.
CastFrom(localMappedFixedPoint);
858 mutable bool m_HaveMadeGetValueWarning{};
865 bool m_UseFloatingPointCorrection{};
871 mutable bool m_ComputeDerivative{};
875 #ifdef ITK_USE_CONCEPT_CHECKING
880 #endif // ITK_USE_CONCEPT_CHECKING
885 #ifndef ITK_MANUAL_INSTANTIATION
886 # include "itkImageToImageMetricv4.hxx"