1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef __clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD_h
20 #define __clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD_h
22 #include "itkImageToImageMetric.h"
23 #include "itkCovariantVector.h"
30 template <class TFixedImage,class TMovingImage >
31 class ITK_EXPORT NormalizedCorrelationImageToImageMetricFor3DBLUTFFD :
32 public itk::ImageToImageMetric< TFixedImage, TMovingImage >
36 /** Standard class typedefs. */
37 typedef NormalizedCorrelationImageToImageMetricFor3DBLUTFFD Self;
38 typedef itk::ImageToImageMetric< TFixedImage, TMovingImage > Superclass;
39 typedef itk::SmartPointer<Self> Pointer;
40 typedef itk::SmartPointer<const Self> ConstPointer;
42 /** Method for creation through the object factory. */
45 /** Run-time type information (and related methods). */
46 itkTypeMacro(NormalizedCorrelationImageToImageMetricFor3DBLUTFFD, ImageToImageMetric);
48 /** Types inherited from Superclass. */
49 typedef typename Superclass::RealType RealType;
50 typedef typename Superclass::TransformType TransformType;
51 typedef typename Superclass::TransformPointer TransformPointer;
52 typedef typename Superclass::TransformJacobianType TransformJacobianType;
53 typedef typename Superclass::InterpolatorType InterpolatorType;
54 typedef typename Superclass::MeasureType MeasureType;
55 typedef typename Superclass::DerivativeType DerivativeType;
56 typedef typename Superclass::ParametersType ParametersType;
57 typedef typename Superclass::FixedImageType FixedImageType;
58 typedef typename Superclass::MovingImageType MovingImageType;
59 typedef typename Superclass::MovingImagePointType MovingImagePointType;
60 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
61 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
62 typedef typename Superclass::CoordinateRepresentationType
63 CoordinateRepresentationType;
64 typedef typename Superclass::FixedImageSampleContainer
65 FixedImageSampleContainer;
66 typedef typename Superclass::ImageDerivativesType ImageDerivativesType;
67 typedef typename Superclass::WeightsValueType WeightsValueType;
68 typedef typename Superclass::IndexValueType IndexValueType;
70 // Needed for evaluation of Jacobian.
71 typedef typename Superclass::FixedImagePointType FixedImagePointType;
74 typedef typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType;
76 /** The moving image dimension. */
77 itkStaticConstMacro( MovingImageDimension, unsigned int,
78 MovingImageType::ImageDimension );
81 /** Set/Get SubtractMean boolean. If true, the sample mean is subtracted
82 * from the sample values in the cross-correlation formula and
83 * typically results in narrower valleys in the cost fucntion.
84 * Default value is false. */
85 itkSetMacro( SubtractMean, bool );
86 itkGetConstReferenceMacro( SubtractMean, bool );
87 itkBooleanMacro( SubtractMean );
90 * Initialize the Metric by
91 * (1) making sure that all the components are present and plugged
93 * (2) uniformly select NumberOfSpatialSamples within
94 * the FixedImageRegion, and
95 * (3) allocate memory for pdf data structures. */
96 #if ( ( ITK_VERSION_MAJOR == 4 ) && ( ITK_VERSION_MINOR > 12 ) || ( ITK_VERSION_MAJOR > 4 ))
97 virtual void Initialize(void) ITK_OVERRIDE;
99 virtual void Initialize(void) throw ( itk::ExceptionObject ) ITK_OVERRIDE;
102 /** Get the value. */
103 MeasureType GetValue( const ParametersType & parameters ) const ITK_OVERRIDE;
105 /** Get the derivatives of the match measure. */
106 void GetDerivative( const ParametersType & parameters,
107 DerivativeType & Derivative ) const ITK_OVERRIDE;
109 /** Get the value and derivatives for single valued optimizers. */
110 void GetValueAndDerivative( const ParametersType & parameters,
112 DerivativeType & Derivative ) const ITK_OVERRIDE;
116 NormalizedCorrelationImageToImageMetricFor3DBLUTFFD();
117 virtual ~NormalizedCorrelationImageToImageMetricFor3DBLUTFFD();
118 void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
122 //purposely not implemented
123 NormalizedCorrelationImageToImageMetricFor3DBLUTFFD(const Self &);
124 //purposely not implemented
125 void operator=(const Self &);
127 /** Get the value for the derivative computation. */
128 MeasureType ComputeSums( const ParametersType & parameters ) const;
131 inline bool GetValueThreadProcessSample( unsigned int threadID,
132 unsigned long fixedImageSample,
133 const MovingImagePointType & mappedPoint,
134 double movingImageValue ) const ITK_OVERRIDE;
137 inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID,
138 unsigned long fixedImageSample,
139 const MovingImagePointType & mappedPoint,
140 double movingImageValue,
141 const ImageDerivativesType &
142 movingImageGradientValue ) const ITK_OVERRIDE;
144 AccumulateType *m_ThreaderSFF, *m_ThreaderSMM, *m_ThreaderSFM, *m_ThreaderSF, *m_ThreaderSM;
145 mutable AccumulateType m_SFF, m_SMM, m_SFM, m_SF, m_SM;
146 mutable RealType m_Denom, m_FixedMean, m_MovingMean;
147 DerivativeType * m_ThreaderDerivativeF, *m_ThreaderDerivativeM;
153 } // end namespace clitk
155 #ifndef ITK_MANUAL_INSTANTIATION
156 #include "clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx"