18#ifndef itkImageToImageMetric_h
19#define itkImageToImageMetric_h
53template <
typename TFixedImage,
typename TMovingImage>
83 static constexpr unsigned int MovingImageDimension = TMovingImage::ImageDimension;
84 static constexpr unsigned int FixedImageDimension = TFixedImage::ImageDimension;
130 using typename Superclass::MeasureType;
133 using typename Superclass::DerivativeType;
136 using typename Superclass::ParametersType;
164 return this->GetNumberOfPixelsCounted();
177#ifndef ITK_FUTURE_LEGACY_REMOVE
181 const auto *
const constArg = arg;
183 this->SetMovingImageMask(constArg);
191#ifndef ITK_FUTURE_LEGACY_REMOVE
195 const auto *
const constArg = arg;
197 this->SetFixedImageMask(constArg);
212 itkGetConstReferenceMacro(UseFixedImageIndexes,
bool);
221 itkSetMacro(ComputeGradient,
bool);
222 itkGetConstReferenceMacro(ComputeGradient,
bool);
223 itkBooleanMacro(ComputeGradient);
241 return m_Transform->GetNumberOfParameters();
266 this->SetNumberOfFixedImageSamples(num);
272 return this->GetNumberOfFixedImageSamples();
285 itkGetConstReferenceMacro(UseFixedImageSamplesIntensityThreshold,
bool);
296 this->SetUseAllPixels(
true);
302 this->SetUseAllPixels(
false);
305 itkGetConstReferenceMacro(UseAllPixels,
bool);
314 itkGetConstReferenceMacro(UseSequentialSampling,
bool);
347 itkSetMacro(UseCachingOfBSplineWeights,
bool);
348 itkGetConstReferenceMacro(UseCachingOfBSplineWeights,
bool);
349 itkBooleanMacro(UseCachingOfBSplineWeights);
358 return m_ThreaderTransform.get();
386 inline friend std::ostream &
390 os <<
"value: " << val.
value << std::endl;
391 os <<
"valueIndex: " << val.
valueIndex << std::endl;
402 bool m_UseFixedImageIndexes{
false };
405 bool m_UseFixedImageSamplesIntensityThreshold{
false };
452 bool m_ComputeGradient{
true };
460 bool m_UseAllPixels{
false };
461 bool m_UseSequentialSampling{
false };
463 bool m_ReseedIterator{
false };
465 mutable int m_RandomSeed{};
473#ifndef ITK_FUTURE_LEGACY_REMOVE
477 bool m_TransformIsBSpline{
false };
484 static constexpr unsigned int DeformationSplineOrder = 3;
522 bool m_UseCachingOfBSplineWeights{
true };
541 double & movingImageValue,
552 double & movingImageValue,
556#ifndef ITK_FUTURE_LEGACY_REMOVE
560 bool m_InterpolatorIsBSpline{
false };
593 : m_ConstMetricPointer{ i2i_metricPointer }
598 return m_ConstMetricPointer;
617 : m_WorkUnitInfo(static_cast<const typename
MultiThreaderType::WorkUnitInfo *>(workunitInfoAsVoid))
622 return m_WorkUnitInfo->WorkUnitID;
638 bool m_WithinThreadPreProcess{
false };
639 bool m_WithinThreadPostProcess{
false };
667 double itkNotUsed(movingImageValue))
const
698 double itkNotUsed(movingImageValue),
720#ifndef ITK_MANUAL_INSTANTIATION
721# include "itkImageToImageMetric.hxx"
Array2D class representing a 2D array.
Evaluates the B-Spline interpolation of an image. Spline order may be from 0 to 5.
Calculate the derivative by central differencing.
A templated class holding a n-Dimensional covariant vector.
Simulate a standard C array with copy semantics.
Computes the gradient of an image by convolution with the first derivative of a Gaussian.
const ImageToImageMetric * GetConstMetricPointer() const
const ImageToImageMetric * m_ConstMetricPointer
ConstantPointerWrapper(ImageToImageMetric *i2i_metricPointer)
~FixedImageSamplePoint()=default
FixedImagePointType point
const ImageToImageMetric * GetConstImageToImageMetricPointer() const
const MultiThreaderType::WorkUnitInfo * m_WorkUnitInfo
MultiThreaderWorkUnitInfoImageToImageMetricWrapper(const void *workunitInfoAsVoid)
ThreadIdType GetThreadId() const
Computes similarity between regions of two images.
typename FixedImageType::ConstPointer FixedImageConstPointer
typename NumericTraits< MovingImagePixelType >::RealType RealType
typename TransformType::Pointer TransformPointer
typename TFixedImage::PixelType FixedImagePixelType
void ReinitializeSeed(int seed)
virtual void SetNumberOfFixedImageSamples(SizeValueType numSamples)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueAndDerivativeMultiThreaded(void *workunitInfoAsVoid)
typename FixedImageType::RegionType FixedImageRegionType
void SetTransformParameters(const ParametersType ¶meters) const
std::vector< FixedImageIndexType > FixedImageIndexContainer
typename BSplineTransformWeightsType::ValueType WeightsValueType
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
virtual void GetValueAndDerivativeThreadPostProcess(ThreadIdType, bool) const
typename MovingImageType::ConstPointer MovingImageConstPointer
void GetValueMultiThreadedPostProcessInitiate() const
std::unique_ptr< ConstantPointerWrapper > m_ConstSelfWrapper
typename MovingImageMaskType::ConstPointer MovingImageMaskConstPointer
typename FixedImageType::IndexType FixedImageIndexType
virtual void TransformPointWithDerivatives(unsigned int sampleNumber, MovingImagePointType &mappedPoint, bool &sampleOk, double &movingImageValue, ImageDerivativesType &movingImageGradient, ThreadIdType threadId) const
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueMultiThreadedPostProcess(void *workunitInfoAsVoid)
typename GradientImageFilterType::Pointer GradientImageFilterPointer
typename BSplineTransformType::ParameterIndexArrayType BSplineTransformIndexArrayType
typename MovingImageMaskType::Pointer MovingImageMaskPointer
const TransformPointer * GetThreaderTransform()
virtual bool GetValueAndDerivativeThreadProcessSample(ThreadIdType, SizeValueType, const MovingImagePointType &, double, const ImageDerivativesType &) const
TFixedImage FixedImageType
std::vector< MovingImagePointType > MovingImagePointArrayType
void SetNumberOfSpatialSamples(SizeValueType num)
virtual void ComputeImageDerivatives(const MovingImagePointType &mappedPoint, ImageDerivativesType &gradient, ThreadIdType threadId) const
void GetValueMultiThreadedInitiate() const
virtual void SampleFixedImageRegion(FixedImageSampleContainer &samples) const
void PrintSelf(std::ostream &os, Indent indent) const override
std::vector< bool > BooleanArrayType
virtual bool GetValueThreadProcessSample(ThreadIdType, SizeValueType, const MovingImagePointType &, double) const
SizeValueType GetNumberOfMovingImageSamples()
typename BSplineTransformIndexArrayType::ValueType IndexValueType
virtual void GetValueThread(ThreadIdType threadId) const
virtual void GetValueThreadPostProcess(ThreadIdType, bool) const
typename BSplineTransformType::WeightsType BSplineTransformWeightsType
typename TransformType::ParametersType TransformParametersType
typename TransformType::OutputPointType MovingImagePointType
void GetValueAndDerivativeMultiThreadedPostProcessInitiate() const
typename TransformType::InputPointType FixedImagePointType
std::unique_ptr< BSplineTransformWeightsType[]> m_ThreaderBSplineTransformWeights
std::unique_ptr< BSplineTransformIndexArrayType[]> m_ThreaderBSplineTransformIndices
virtual void SynchronizeTransforms() const
void SetUseSequentialSampling(bool useSequential)
typename Superclass::ParametersValueType CoordinateRepresentationType
std::unique_ptr< unsigned int[]> m_ThreaderNumberOfMovingImageSamples
void GetValueAndDerivativeMultiThreadedInitiate() const
typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer
unsigned int GetNumberOfParameters() const override
SizeValueType GetNumberOfSpatialSamples()
void SetUseAllPixels(bool useAllPixels)
void SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
typename FixedImageMaskType::Pointer FixedImageMaskPointer
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueAndDerivativeMultiThreadedPostProcess(void *workunitInfoAsVoid)
virtual void MultiThreadingInitialize()
virtual void Initialize()
virtual void GetValueThreadPreProcess(ThreadIdType, bool) const
typename TMovingImage::PixelType MovingImagePixelType
virtual void SampleFixedImageIndexes(FixedImageSampleContainer &samples) const
~ImageToImageMetric() override=default
std::vector< FixedImageSamplePoint > FixedImageSampleContainer
TMovingImage MovingImageType
void SetUseFixedImageIndexes(bool useIndexes)
std::unique_ptr< TransformPointer[]> m_ThreaderTransform
virtual void TransformPoint(unsigned int sampleNumber, MovingImagePointType &mappedPoint, bool &sampleOk, double &movingImageValue, ThreadIdType threadId) const
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueMultiThreaded(void *workunitInfoAsVoid)
virtual void SampleFullFixedImageRegion(FixedImageSampleContainer &samples) const
void SetFixedImageSamplesIntensityThreshold(const FixedImagePixelType &thresh)
void SetUseFixedImageSamplesIntensityThreshold(bool useThresh)
void SetFixedImageIndexes(const FixedImageIndexContainer &indexes)
typename MovingImageType::IndexType MovingImageIndexType
virtual void GetValueAndDerivativeThreadPreProcess(ThreadIdType, bool) const
typename TransformType::OutputPointType OutputPointType
virtual void GetValueAndDerivativeThread(ThreadIdType threadId) const
virtual void SetFixedImageRegion(const FixedImageRegionType reg)
typename InterpolatorType::Pointer InterpolatorPointer
typename TransformType::JacobianType TransformJacobianType
virtual void ComputeGradient()
virtual void PreComputeTransformValues()
typename TransformType::InputPointType InputPointType
Templated n-dimensional image class.
Control indentation during Print() invocation.
Base class for all image interpolators.
Light weight base class for most itk classes.
A class for performing multithreaded execution.
Class to hold and manage different parameter types used during optimization.
A templated class holding a geometric point in n-Dimensional space.
This class is a base for the CostFunctions returning a single value.
Superclass::ParametersType ParametersType
Implementation of the composite pattern.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
ImageBaseType::RegionType RegionType
ImageBaseType::IndexType IndexType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
unsigned int ThreadIdType
unsigned long SizeValueType
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION