18#ifndef itkAdvancedImageToImageMetric_h
19#define itkAdvancedImageToImageMetric_h
21#include "itkImageToImageMetric.h"
24#include "itkGradientImageFilter.h"
25#include "itkBSplineInterpolateImageFunction.h"
29#include "itkFixedArray.h"
32#include "itkImageMaskSpatialObject.h"
81template <
class TFixedImage,
class TMovingImage>
89 using Superclass = ImageToImageMetric<TFixedImage, TMovingImage>;
101 using typename Superclass::CoordinateRepresentationType;
102 using typename Superclass::MovingImageType;
103 using typename Superclass::MovingImagePixelType;
105 using typename Superclass::MovingImageConstPointer;
106 using typename Superclass::FixedImageType;
108 using typename Superclass::FixedImageConstPointer;
109 using typename Superclass::FixedImageRegionType;
110 using typename Superclass::TransformType;
111 using typename Superclass::TransformPointer;
112 using typename Superclass::InputPointType;
113 using typename Superclass::OutputPointType;
114 using typename Superclass::TransformParametersType;
115 using typename Superclass::TransformJacobianType;
116 using typename Superclass::InterpolatorType;
117 using typename Superclass::InterpolatorPointer;
118 using typename Superclass::RealType;
119 using typename Superclass::GradientPixelType;
120 using typename Superclass::GradientImageType;
121 using typename Superclass::GradientImagePointer;
131 using typename Superclass::MeasureType;
132 using typename Superclass::DerivativeType;
134 using typename Superclass::ParametersType;
178 Superclass::SetFixedImageMask(arg);
185 Superclass::SetMovingImageMask(arg);
188 const FixedImageMaskType *
191 const auto *
const mask = Superclass::GetFixedImageMask();
196 const MovingImageMaskType *
199 const auto *
const mask = Superclass::GetMovingImageMask();
208 this->Superclass::SetTransform(arg);
218 AdvancedTransformType *
225 const AdvancedTransformType *
243 itkGetConstMacro(UseImageSampler,
bool);
248 itkSetMacro(RequiredRatioOfValidSamples,
double);
249 itkGetConstMacro(RequiredRatioOfValidSamples,
double);
264 itkSetMacro(MovingLimitRangeRatio,
double);
265 itkGetConstMacro(MovingLimitRangeRatio,
double);
266 itkSetMacro(FixedLimitRangeRatio,
double);
267 itkGetConstMacro(FixedLimitRangeRatio,
double);
271 itkGetConstMacro(UseFixedImageLimiter,
bool);
272 itkGetConstMacro(UseMovingImageLimiter,
bool);
281 itkSetMacro(UseMovingImageDerivativeScales,
bool);
282 itkGetConstMacro(UseMovingImageDerivativeScales,
bool);
284 itkSetMacro(ScaleGradientWithRespectToMovingImageOrientation,
bool);
285 itkGetConstMacro(ScaleGradientWithRespectToMovingImageOrientation,
bool);
302 itkSetMacro(UseMetricSingleThreaded,
bool);
303 itkGetConstReferenceMacro(UseMetricSingleThreaded,
bool);
304 itkBooleanMacro(UseMetricSingleThreaded);
308 itkSetMacro(UseMultiThread,
bool);
309 itkGetConstReferenceMacro(UseMultiThread,
bool);
310 itkBooleanMacro(UseMultiThread);
329 PrintSelf(std::ostream & os, Indent indent)
const override;
343 BSplineInterpolateImageFunction<MovingImageType, CoordinateRepresentationType, double>;
346 BSplineInterpolateImageFunction<MovingImageType, CoordinateRepresentationType, float>;
392 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
408 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
416 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
453 GetValueAndDerivativePerThreadStruct,
454 PaddedGetValueAndDerivativePerThreadStruct);
456 PaddedGetValueAndDerivativePerThreadStruct,
457 AlignedGetValueAndDerivativePerThreadStruct);
477 itkSetMacro(UseImageSampler,
bool);
501 RealType & movingImageValue,
511 RealType & movingImageValue,
513 const ThreadIdType threadId)
const
525 DerivativeType & imageJacobian)
const;
552 TransformJacobianType & jacobian,
566 itkSetMacro(UseFixedImageLimiter,
bool);
567 itkSetMacro(UseMovingImageLimiter,
bool);
576 itkExceptionMacro(
"Intentionally left unimplemented!");
582 itkExceptionMacro(
"Intentionally left unimplemented!");
588 itkExceptionMacro(
"Intentionally left unimplemented!");
594 itkExceptionMacro(
"Intentionally left unimplemented!");
598 using Superclass::SetTransform;
601 template <
typename... TOptionalThreadId>
604 RealType & movingImageValue,
606 const TOptionalThreadId... optionalThreadId)
const;
627 using Superclass::TransformPoint;
639#ifndef ITK_MANUAL_INSTANTIATION
640# include "itkAdvancedImageToImageMetric.hxx"
MovingImagePixelType m_MovingImageTrueMin
MovingImageDerivativeScalesType m_MovingImageDerivativeScales
itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension)
MovingImageLimiterOutputType m_MovingImageMaxLimit
virtual void AfterThreadedGetValue(MeasureType &) const
virtual bool IsInsideMovingMask(const MovingImagePointType &point) const
static constexpr DummyMask m_FixedImageMask
virtual void ThreadedGetValueAndDerivative(ThreadIdType) const
const MovingImageMaskType * GetMovingImageMask() const override
typename BSplineOrder1TransformType::Pointer BSplineOrder1TransformPointer
void Initialize() override
typename TransformType::OutputPointType MovingImagePointType
typename ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
void PrintSelf(std::ostream &os, Indent indent) const override
ITK_DISALLOW_COPY_AND_MOVE(AdvancedImageToImageMetric)
bool m_TransformIsBSpline
ThreadIdType m_GetValueAndDerivativePerThreadVariablesSize
ImageToImageMetric< TFixedImage, TMovingImage > Superclass
typename MovingImageType::RegionType MovingImageRegionType
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
bool m_UseFixedImageLimiter
virtual bool EvaluateMovingImageValueAndDerivative(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient) const
MovingImageLimiterPointer m_MovingImageLimiter
void CheckForAdvancedTransform()
AdvancedImageToImageMetric Self
FixedArray< double, Self::MovingImageDimension > MovingImageDerivativeScalesType
AdvancedTransformType::Pointer m_AdvancedTransform
typename FixedImageType::PixelType FixedImagePixelType
AdvancedLinearInterpolateImageFunction< MovingImageType, CoordinateRepresentationType > LinearInterpolatorType
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, float > BSplineInterpolatorFloatType
bool m_UseMetricSingleThreaded
typename DerivativeType::ValueType DerivativeValueType
bool m_UseMovingImageDerivativeScales
AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 3 > BSplineOrder3TransformType
FixedImagePixelType m_FixedImageTrueMin
typename FixedImageLimiterType::Pointer FixedImageLimiterPointer
void CheckNumberOfSamples(unsigned long wanted, unsigned long found) const
double m_MovingLimitRangeRatio
virtual void InitializeImageSampler()
void SetFixedImageMask(const typename Superclass::FixedImageMaskType *) final
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
typename MovingImageType::IndexType MovingImageIndexType
virtual void SetTransform(AdvancedTransformType *arg)
void LaunchGetValueAndDerivativeThreaderCallback() const
typename ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueAndDerivativeThreaderCallback(void *arg)
typename MovingImageType::Pointer MovingImagePointer
BSplineInterpolatorFloatPointer m_BSplineInterpolatorFloat
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
bool FastEvaluateMovingImageValueAndDerivative(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient, const ThreadIdType threadId) const
void SetFixedImageMask(typename Superclass::FixedImageMaskType *) final
typename BSplineOrder3TransformType::Pointer BSplineOrder3TransformPointer
void LaunchGetValueThreaderCallback() const
virtual void InitializeThreadingParameters() const
~AdvancedImageToImageMetric() override=default
typename FixedImageType::Pointer FixedImagePointer
ImageSamplerPointer m_ImageSampler
typename ReducedBSplineInterpolatorType::Pointer ReducedBSplineInterpolatorPointer
virtual void BeforeThreadedGetValueAndDerivative(const TransformParametersType ¶meters) const
typename BSplineOrder2TransformType::Pointer BSplineOrder2TransformPointer
bool m_UseMovingImageLimiter
bool m_ScaleGradientWithRespectToMovingImageOrientation
AdvancedTransform< ScalarType, FixedImageDimension, MovingImageDimension > AdvancedTransformType
typename FixedImageType::IndexType FixedImageIndexType
BSplineInterpolatorPointer m_BSplineInterpolator
virtual void ThreadedGetValue(ThreadIdType) const
MovingImageLimiterOutputType m_MovingImageMinLimit
double m_FixedLimitRangeRatio
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedGetValueAndDerivativePerThreadStruct, AlignedGetValueAndDerivativePerThreadStruct)
AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 1 > BSplineOrder1TransformType
LimiterFunctionBase< RealType, FixedImageDimension > FixedImageLimiterType
AdvancedImageToImageMetric()
typename BSplineInterpolatorType::Pointer BSplineInterpolatorPointer
bool EvaluateMovingImageValueAndDerivativeWithOptionalThreadId(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient, const TOptionalThreadId... optionalThreadId) const
ImageSamplerBase< FixedImageType > ImageSamplerType
FixedImageLimiterPointer m_FixedImageLimiter
FixedImageLimiterOutputType m_FixedImageMinLimit
MultiThreaderBase::WorkUnitInfo ThreadInfoType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
void CheckForBSplineTransform() const
virtual void AfterThreadedGetValueAndDerivative(MeasureType &, DerivativeType &) const
ReducedBSplineInterpolatorPointer m_ReducedBSplineInterpolator
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION AccumulateDerivativesThreaderCallback(void *arg)
FixedImagePixelType m_FixedImageTrueMax
virtual void SetMovingImageMask(const MovingImageMaskType *const arg)
virtual void EvaluateTransformJacobianInnerProduct(const TransformJacobianType &jacobian, const MovingImageDerivativeType &movingImageDerivative, DerivativeType &imageJacobian) const
std::unique_ptr< AlignedGetValueAndDerivativePerThreadStruct[]> m_GetValueAndDerivativePerThreadVariables
FixedImageLimiterOutputType m_FixedImageMaxLimit
SmartPointer< const Self > ConstPointer
LimiterFunctionBase< RealType, MovingImageDimension > MovingImageLimiterType
const FixedImageMaskType * GetFixedImageMask() const override
MovingImagePointType TransformPoint(const FixedImagePointType &fixedImagePoint) const
typename MovingImageLimiterType::OutputType MovingImageLimiterOutputType
ImageSamplerType * GetImageSampler() const
typename TransformType::InputPointType FixedImagePointType
const AdvancedTransformType * GetTransform() const override
double m_RequiredRatioOfValidSamples
void SetMovingImageMask(const typename Superclass::MovingImageMaskType *) final
typename FixedImageLimiterType::OutputType FixedImageLimiterOutputType
void InitializeLimiters()
SmartPointer< FixedImageMaskType > FixedImageMaskPointer
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
void SetMovingImageMask(typename Superclass::MovingImageMaskType *) final
typename BSplineInterpolatorFloatType::Pointer BSplineInterpolatorFloatPointer
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
AdvancedTransformType * GetTransform() override
ReducedDimensionBSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > ReducedBSplineInterpolatorType
typename TransformType::ScalarType ScalarType
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueThreaderCallback(void *arg)
virtual void SetFixedImageMask(const FixedImageMaskType *const arg)
SmartPointer< const FixedImageMaskType > FixedImageMaskConstPointer
typename ImageSamplerType::Pointer ImageSamplerPointer
bool EvaluateTransformJacobian(const FixedImagePointType &fixedImagePoint, TransformJacobianType &jacobian, NonZeroJacobianIndicesType &nzji) const
typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
AdvancedCombinationTransform< ScalarType, FixedImageDimension > CombinationTransformType
typename AdvancedTransformType::NumberOfParametersType NumberOfParametersType
AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 2 > BSplineOrder2TransformType
static constexpr DummyMask m_MovingImageMask
SmartPointer< const MovingImageMaskType > MovingImageMaskConstPointer
void CheckForBSplineInterpolator()
typename MovingImageLimiterType::Pointer MovingImageLimiterPointer
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, GetValueAndDerivativePerThreadStruct, PaddedGetValueAndDerivativePerThreadStruct)
MovingImagePixelType m_MovingImageTrueMax
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
MultiThreaderParameterType m_ThreaderMetricParameters
typename LinearInterpolatorType::Pointer LinearInterpolatorPointer
LinearInterpolatorPointer m_LinearInterpolator
Linearly interpolate an image at specified positions.
SmartPointer< Self > Pointer
This class is a base class for any image sampler.
typename OutputVectorContainerType::Pointer OutputVectorContainerPointer
VectorDataContainer< std::vcl_size_t, ImageSample< FixedImageType > > OutputVectorContainerType
SmartPointer< Self > Pointer
Base class for all ITK limiter function objects.
SmartPointer< Self > Pointer
Evaluates the B-Spline interpolation of an image. Spline order may be from 0 to 5.
SmartPointer< Self > Pointer
DerivativeType st_Derivative
SizeValueType st_NumberOfPixelsCounted
DerivativeValueType st_NormalizationFactor
DerivativeValueType * st_DerivativePointer
AdvancedImageToImageMetric * st_Metric