]> Creatis software - clitk.git/blob - registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h
Moved from repository clitk to clitk.private/tests_dav
[clitk.git] / registration / itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.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 /*=========================================================================
20
21   Program:   Insight Segmentation & Registration Toolkit
22   Module:    $RCSfile: itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h,v $
23   Language:  C++
24   Date:      $Date: 2010/06/14 17:32:07 $
25   Version:   $Revision: 1.1 $
26
27   Copyright (c) Insight Software Consortium. All rights reserved.
28   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
29
30      This software is distributed WITHOUT ANY WARRANTY; without even
31      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
32      PURPOSE.  See the above copyright notices for more information.
33
34 =========================================================================*/
35 #ifndef __itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD_h
36 #define __itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD_h
37
38 #if ITK_VERSION_MAJOR >= 4
39   #include "itkImageToImageMetric.h"
40 #else
41   #include "itkOptImageToImageMetric.h"
42 #endif
43 #include "itkCovariantVector.h"
44 #include "itkPoint.h"
45 #include "itkIndex.h"
46
47 #include "itkMultiThreader.h"
48
49 namespace itk
50 {
51
52 template <class TFixedImage,class TMovingImage >
53 class ITK_EXPORT MeanSquaresImageToImageMetricFor3DBLUTFFD :
54   public ImageToImageMetric< TFixedImage, TMovingImage >
55 {
56 public:
57
58   /** Standard class typedefs. */
59   typedef MeanSquaresImageToImageMetricFor3DBLUTFFD                     Self;
60   typedef ImageToImageMetric< TFixedImage, TMovingImage >   Superclass;
61   typedef SmartPointer<Self>                                Pointer;
62   typedef SmartPointer<const Self>                          ConstPointer;
63
64   /** Method for creation through the object factory. */
65   itkNewMacro(Self);
66
67   /** Run-time type information (and related methods). */
68   itkTypeMacro(MeanSquaresImageToImageMetricFor3DBLUTFFD, ImageToImageMetric);
69
70   /** Types inherited from Superclass. */
71   typedef typename Superclass::TransformType            TransformType;
72   typedef typename Superclass::TransformPointer         TransformPointer;
73   typedef typename Superclass::TransformJacobianType    TransformJacobianType;
74   typedef typename Superclass::InterpolatorType         InterpolatorType;
75   typedef typename Superclass::MeasureType              MeasureType;
76   typedef typename Superclass::DerivativeType           DerivativeType;
77   typedef typename Superclass::ParametersType           ParametersType;
78   typedef typename Superclass::FixedImageType           FixedImageType;
79   typedef typename Superclass::MovingImageType          MovingImageType;
80   typedef typename Superclass::MovingImagePointType     MovingImagePointType;
81   typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
82   typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
83   typedef typename Superclass::CoordinateRepresentationType
84   CoordinateRepresentationType;
85   typedef typename Superclass::FixedImageSampleContainer
86   FixedImageSampleContainer;
87   typedef typename Superclass::ImageDerivativesType     ImageDerivativesType;
88   typedef typename Superclass::WeightsValueType         WeightsValueType;
89   typedef typename Superclass::IndexValueType           IndexValueType;
90
91   // Needed for evaluation of Jacobian.
92   typedef typename Superclass::FixedImagePointType     FixedImagePointType;
93
94   /** The moving image dimension. */
95   itkStaticConstMacro( MovingImageDimension, unsigned int,
96                        MovingImageType::ImageDimension );
97
98   /**
99    *  Initialize the Metric by
100    *  (1) making sure that all the components are present and plugged
101    *      together correctly,
102    *  (2) uniformly select NumberOfSpatialSamples within
103    *      the FixedImageRegion, and
104    *  (3) allocate memory for pdf data structures. */
105   virtual void Initialize(void) throw ( ExceptionObject );
106
107   /**  Get the value. */
108   MeasureType GetValue( const ParametersType & parameters ) const;
109
110   /** Get the derivatives of the match measure. */
111   void GetDerivative( const ParametersType & parameters,
112                       DerivativeType & Derivative ) const;
113
114   /**  Get the value and derivatives for single valued optimizers. */
115   void GetValueAndDerivative( const ParametersType & parameters,
116                               MeasureType & Value,
117                               DerivativeType & Derivative ) const;
118
119 protected:
120
121   MeanSquaresImageToImageMetricFor3DBLUTFFD();
122   virtual ~MeanSquaresImageToImageMetricFor3DBLUTFFD();
123   void PrintSelf(std::ostream& os, Indent indent) const;
124
125 private:
126
127   //purposely not implemented
128   MeanSquaresImageToImageMetricFor3DBLUTFFD(const Self &);
129   //purposely not implemented
130   void operator=(const Self &);
131
132   inline bool GetValueThreadProcessSample( unsigned int threadID,
133       unsigned long fixedImageSample,
134       const MovingImagePointType & mappedPoint,
135       double movingImageValue ) const;
136
137   inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID,
138       unsigned long fixedImageSample,
139       const MovingImagePointType & mappedPoint,
140       double movingImageValue,
141       const ImageDerivativesType &
142       movingImageGradientValue ) const;
143
144   MeasureType    * m_ThreaderMSE;
145   DerivativeType * m_ThreaderMSEDerivatives;
146
147 };
148
149 } // end namespace itk
150
151 #ifndef ITK_MANUAL_INSTANTIATION
152 #include "itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx"
153 #endif
154
155 #endif