]> Creatis software - clitk.git/blob - registration/clitkNormalizedCorrelationImageToImageMetric.h
Merge branch 'master' of /home/romulo/creatis/clitk3-git-shared/clitk3
[clitk.git] / registration / clitkNormalizedCorrelationImageToImageMetric.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
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
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18
19 #ifndef _clitkNormalizedCorrelationImageToImageMetric_h
20 #define _clitkNormalizedCorrelationImageToImageMetric_h
21
22 // First make sure that the configuration is available.
23 // This line can be removed once the optimized versions
24 // gets integrated into the main directories.
25 #include "itkConfigure.h"
26
27 #ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
28 #include "clitkOptNormalizedCorrelationImageToImageMetric.h"
29 #else
30
31 #include "itkImageToImageMetric.h"
32 #include "itkCovariantVector.h"
33 #include "itkPoint.h"
34
35
36 namespace clitk
37 {
38
39 template < class TFixedImage, class TMovingImage >
40 class ITK_EXPORT NormalizedCorrelationImageToImageMetric :
41   public itk::ImageToImageMetric< TFixedImage, TMovingImage>
42 {
43 public:
44
45   /** Standard class typedefs. */
46   typedef NormalizedCorrelationImageToImageMetric    Self;
47   typedef itk::ImageToImageMetric<TFixedImage, TMovingImage >  Superclass;
48
49   typedef itk::SmartPointer<Self>         Pointer;
50   typedef itk::SmartPointer<const Self>   ConstPointer;
51
52   /** Method for creation through the object factory. */
53   itkNewMacro(Self);
54
55   /** Run-time type information (and related methods). */
56   itkTypeMacro(NormalizedCorrelationImageToImageMetric, itk::Object);
57
58
59   /** Types transferred from the base class */
60   typedef typename Superclass::RealType                 RealType;
61   typedef typename Superclass::TransformType            TransformType;
62   typedef typename Superclass::TransformPointer         TransformPointer;
63   typedef typename Superclass::TransformParametersType  TransformParametersType;
64   typedef typename Superclass::TransformJacobianType    TransformJacobianType;
65   typedef typename Superclass::GradientPixelType        GradientPixelType;
66   typedef typename Superclass::OutputPointType          OutputPointType;
67   typedef typename Superclass::InputPointType           InputPointType;
68
69   typedef typename Superclass::MeasureType              MeasureType;
70   typedef typename Superclass::DerivativeType           DerivativeType;
71   typedef typename Superclass::FixedImageType           FixedImageType;
72   typedef typename Superclass::MovingImageType          MovingImageType;
73   typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
74   typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
75
76
77   /** Get the derivatives of the match measure. */
78   void GetDerivative( const TransformParametersType & parameters,
79                       DerivativeType & Derivative ) const;
80
81   /**  Get the value for single valued optimizers. */
82   MeasureType GetValue( const TransformParametersType & parameters ) const;
83
84   /**  Get value and derivatives for multiple valued optimizers. */
85   void GetValueAndDerivative( const TransformParametersType & parameters,
86                               MeasureType& Value, DerivativeType& Derivative ) const;
87
88   /** Set/Get SubtractMean boolean. If true, the sample mean is subtracted
89    * from the sample values in the cross-correlation formula and
90    * typically results in narrower valleys in the cost fucntion.
91    * Default value is false. */
92   itkSetMacro( SubtractMean, bool );
93   itkGetConstReferenceMacro( SubtractMean, bool );
94   itkBooleanMacro( SubtractMean );
95
96 protected:
97   NormalizedCorrelationImageToImageMetric();
98   virtual ~NormalizedCorrelationImageToImageMetric() {};
99   void PrintSelf(std::ostream& os, itk::Indent indent) const;
100
101 private:
102   NormalizedCorrelationImageToImageMetric(const Self&); //purposely not implemented
103   void operator=(const Self&); //purposely not implemented
104
105   bool    m_SubtractMean;
106
107 };
108
109 } // end namespace clitk
110
111 #ifndef ITK_MANUAL_INSTANTIATION
112 #include "clitkNormalizedCorrelationImageToImageMetric.txx"
113 #endif
114
115 #endif // opt
116
117 #endif // _clitkNormalizedCorrelationImageToImageMetric.txx
118
119