18 #ifndef itkImageToImageMetric_h
19 #define itkImageToImageMetric_h
50 template<
typename TFixedImage,
typename TMovingImage >
81 static constexpr
unsigned int MovingImageDimension = TMovingImage::ImageDimension;
82 static constexpr
unsigned int FixedImageDimension = TFixedImage::ImageDimension;
86 Self::MovingImageDimension,
87 Self::FixedImageDimension >;
163 return this->GetNumberOfPixelsCounted();
166 itkGetConstReferenceMacro(NumberOfPixelsCounted,
SizeValueType);
169 virtual void SetFixedImageRegion(
const FixedImageRegionType reg);
172 itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);
175 itkSetObjectMacro(MovingImageMask, MovingImageMaskType);
176 itkSetConstObjectMacro(MovingImageMask, MovingImageMaskType);
177 itkGetConstObjectMacro(MovingImageMask, MovingImageMaskType);
181 itkSetObjectMacro(FixedImageMask, FixedImageMaskType);
182 itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
183 itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
188 void SetFixedImageIndexes(
const FixedImageIndexContainer & indexes);
190 void SetUseFixedImageIndexes(
bool useIndex);
192 itkGetConstReferenceMacro(UseFixedImageIndexes,
bool);
195 void SetNumberOfWorkUnits(
ThreadIdType numberOfThreads);
196 itkGetConstReferenceMacro(NumberOfWorkUnits,
ThreadIdType);
200 itkSetMacro(ComputeGradient,
bool);
201 itkGetConstReferenceMacro(ComputeGradient,
bool);
202 itkBooleanMacro(ComputeGradient);
206 virtual void ComputeGradient();
209 itkGetModifiableObjectMacro(GradientImage, GradientImageType);
212 void SetTransformParameters(
const ParametersType & parameters)
const;
217 return m_Transform->GetNumberOfParameters();
222 virtual void Initialize();
225 virtual void MultiThreadingInitialize();
229 virtual void SetNumberOfFixedImageSamples(
SizeValueType numSamples);
230 itkGetConstReferenceMacro(NumberOfFixedImageSamples,
SizeValueType);
237 this->SetNumberOfFixedImageSamples(num);
242 return this->GetNumberOfFixedImageSamples();
247 void SetFixedImageSamplesIntensityThreshold(
const FixedImagePixelType & thresh);
249 itkGetConstReferenceMacro(FixedImageSamplesIntensityThreshold, FixedImagePixelType);
251 void SetUseFixedImageSamplesIntensityThreshold(
bool useThresh);
253 itkGetConstReferenceMacro(UseFixedImageSamplesIntensityThreshold,
bool);
258 void SetUseAllPixels(
bool useAllPixels);
262 this->SetUseAllPixels(
true);
267 this->SetUseAllPixels(
false);
270 itkGetConstReferenceMacro(UseAllPixels,
bool);
276 void SetUseSequentialSampling(
bool sequentialSampling);
278 itkGetConstReferenceMacro(UseSequentialSampling,
bool);
289 void ReinitializeSeed();
290 void ReinitializeSeed(
int seed);
309 itkSetMacro(UseCachingOfBSplineWeights,
bool);
310 itkGetConstReferenceMacro(UseCachingOfBSplineWeights,
bool);
311 itkBooleanMacro(UseCachingOfBSplineWeights);
319 return m_ThreaderTransform;
327 void PrintSelf(std::ostream & os,
Indent indent)
const override;
352 bool m_UseFixedImageIndexes{
false};
355 bool m_UseFixedImageSamplesIntensityThreshold{
false};
393 bool m_ComputeGradient{
true};
401 bool m_UseAllPixels{
false};
402 bool m_UseSequentialSampling{
false};
404 bool m_ReseedIterator{
false};
415 bool m_TransformIsBSpline{
false};
421 static constexpr
unsigned int DeformationSplineOrder = 3;
424 FixedImageType ::ImageDimension,
425 Self::DeformationSplineOrder >;
463 bool m_UseCachingOfBSplineWeights{
true};
470 virtual void PreComputeTransformValues();
474 virtual void TransformPoint(
unsigned int sampleNumber,
476 bool & sampleWithinSupportRegion,
477 double & movingImageValue,
480 virtual void TransformPointWithDerivatives(
unsigned int sampleNumber,
482 bool & sampleWithinSupportRegion,
483 double & movingImageValue,
488 bool m_InterpolatorIsBSpline{
false};
517 : m_ConstMetricPointer{ i2i_metricPointer }
541 return (static_cast<ConstantPointerWrapper *>( m_WorkUnitInfo ->UserData))->GetConstMetricPointer();
550 mutable unsigned int * m_ThreaderNumberOfMovingImageSamples{
nullptr};
551 bool m_WithinThreadPreProcess{
false};
552 bool m_WithinThreadPostProcess{
false};
554 void GetValueMultiThreadedInitiate()
const;
556 void GetValueMultiThreadedPostProcessInitiate()
const;
562 virtual inline void GetValueThread(
ThreadIdType threadId)
const;
566 bool itkNotUsed(withinSampleThread) )
const
572 double itkNotUsed(movingImageValue) )
const
576 bool itkNotUsed(withinSampleThread) )
const
579 void GetValueAndDerivativeMultiThreadedInitiate()
const;
581 void GetValueAndDerivativeMultiThreadedPostProcessInitiate()
const;
587 virtual inline void GetValueAndDerivativeThread(
ThreadIdType threadId)
const;
591 bool itkNotUsed(withinSampleThread) )
const
597 double itkNotUsed(movingImageValue),
602 bool itkNotUsed(withinSampleThread) )
const
608 virtual void SynchronizeTransforms()
const;
615 #ifndef ITK_MANUAL_INSTANTIATION
616 #include "itkImageToImageMetric.hxx"
typename FixedImageType::RegionType FixedImageRegionType
virtual bool GetValueAndDerivativeThreadProcessSample(ThreadIdType, SizeValueType, const MovingImagePointType &, double, const ImageDerivativesType &) const
Array class with size defined at construction time.
MultiThreaderWorkUnitInfoImageToImageMetricWrapper(const void *workunitInfoAsVoid)
virtual void GetValueThreadPostProcess(ThreadIdType, bool) const
typename BSplineTransformWeightsType::ValueType WeightsValueType
virtual void GetValueThreadPreProcess(ThreadIdType, bool) const
BSplineTransformIndexArrayType m_BSplineTransformIndices
This class is a base for the CostFunctions returning a single value.
Light weight base class for most itk classes.
TransformPointer m_Transform
SizeValueType GetNumberOfSpatialSamples()
MovingImageMaskConstPointer m_MovingImageMask
typename TransformType::InputPointType FixedImagePointType
unsigned int GetNumberOfParameters() const override
typename TransformType::InputPointType InputPointType
Define numeric traits for std::vector.
typename BSplineTransformType::WeightsType BSplineTransformWeightsType
std::vector< FixedImageIndexType > FixedImageIndexContainer
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
typename TransformType::JacobianType TransformJacobianType
unsigned long SizeValueType
virtual void GetValueAndDerivativeThreadPreProcess(ThreadIdType, bool) const
void SetNumberOfSpatialSamples(SizeValueType num)
BSplineParametersOffsetType m_BSplineParametersOffset
FixedImageIndexContainer m_FixedImageIndexes
TransformPointer * m_ThreaderTransform
typename GradientImageFilterType::Pointer GradientImageFilterPointer
BSplineTransformType::Pointer m_BSplineTransform
BSplineTransformWeightsArrayType m_BSplineTransformWeightsArray
BSplineTransformIndicesArrayType m_BSplineTransformIndicesArray
BSplineTransformWeightsType m_BSplineTransformWeights
FixedImagePointType point
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
Computes the gradient of an image by convolution with the first derivative of a Gaussian.
Calculate the derivative by central differencing.
const ImageToImageMetric * GetConstImageToImageMetricPointer() const
ConstantPointerWrapper(ImageToImageMetric *i2i_metricPointer)
const MultiThreaderType::WorkUnitInfo * m_WorkUnitInfo
MovingImageConstPointer m_MovingImage
const TransformPointer * GetThreaderTransform()
typename TMovingImage::PixelType MovingImagePixelType
FixedImageSampleContainer m_FixedImageSamples
typename FixedImageType::IndexType FixedImageIndexType
MovingImagePointArrayType m_BSplinePreTransformPointsArray
std::vector< bool > BooleanArrayType
Array2D class representing a 2D array with size defined at construction time.
ThreadIdType GetThreadId() const
BooleanArrayType m_WithinBSplineSupportRegionArray
ImageBaseType::IndexType IndexType
ConstantPointerWrapper * m_ConstSelfWrapper
TMovingImage MovingImageType
signed long IndexValueType
typename TransformType::ParametersType TransformParametersType
Implementation of the composite pattern.
typename Superclass::ParametersValueType CoordinateRepresentationType
typename MovingImageMaskType::ConstPointer MovingImageMaskConstPointer
FixedImageConstPointer m_FixedImage
std::vector< FixedImageSamplePoint > FixedImageSampleContainer
A class for performing multithreaded execution.
InterpolatorPointer m_Interpolator
typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer
typename TransformType::OutputPointType OutputPointType
GradientImagePointer m_GradientImage
virtual bool GetValueThreadProcessSample(ThreadIdType, SizeValueType, const MovingImagePointType &, double) const
typename FixedImageType::ConstPointer FixedImageConstPointer
BSplineTransformWeightsType * m_ThreaderBSplineTransformWeights
unsigned int ThreadIdType
typename InterpolatorType::Pointer InterpolatorPointer
Base class for all image interpolaters.
BSplineInterpolatorType::Pointer m_BSplineInterpolator
FixedImageMaskConstPointer m_FixedImageMask
DerivativeFunctionType::Pointer m_DerivativeCalculator
typename TransformType::Pointer TransformPointer
typename TFixedImage::PixelType FixedImagePixelType
typename BSplineTransformType::ParameterIndexArrayType BSplineTransformIndexArrayType
FixedImageRegionType m_FixedImageRegion
typename NumericTraits< MovingImagePixelType >::RealType RealType
FixedImagePixelType m_FixedImageSamplesIntensityThreshold
TFixedImage FixedImageType
typename FixedImageMaskType::Pointer FixedImageMaskPointer
typename MovingImageType::IndexType MovingImageIndexType
typename MovingImageMaskType::Pointer MovingImageMaskPointer
Control indentation during Print() invocation.
virtual void GetValueAndDerivativeThreadPostProcess(ThreadIdType, bool) const
Evaluates the B-Spline interpolation of an image. Spline order may be from 0 to 5.
BSplineTransformIndexArrayType * m_ThreaderBSplineTransformIndices
const ImageToImageMetric * GetConstMetricPointer() const
ImageBaseType::RegionType RegionType
Computes similarity between regions of two images.
A templated class holding a geometric point in n-Dimensional space.
A templated class holding a n-Dimensional covariant vector.
std::vector< MovingImagePointType > MovingImagePointArrayType
SizeValueType GetNumberOfMovingImageSamples()
typename MovingImageType::ConstPointer MovingImageConstPointer
typename BSplineTransformIndexArrayType::ValueType IndexValueType
Templated n-dimensional image class.
MultiThreaderType::Pointer m_Threader
typename TransformType::OutputPointType MovingImagePointType
const ImageToImageMetric * m_ConstMetricPointer