]> Creatis software - clitk.git/blob - registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h
ffa6ac959daad7e29b073bd3ec02fae5ff93bd3f
[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 #include "itkImageToImageMetric.h"
39 #include "itkCovariantVector.h"
40 #include "itkPoint.h"
41 #include "itkIndex.h"
42
43 #include "itkMultiThreader.h"
44
45 namespace itk
46 {
47
48 template <class TFixedImage,class TMovingImage >
49 class ITK_EXPORT MeanSquaresImageToImageMetricFor3DBLUTFFD :
50   public ImageToImageMetric< TFixedImage, TMovingImage >
51 {
52 public:
53
54   /** Standard class typedefs. */
55   typedef MeanSquaresImageToImageMetricFor3DBLUTFFD                     Self;
56   typedef ImageToImageMetric< TFixedImage, TMovingImage >   Superclass;
57   typedef SmartPointer<Self>                                Pointer;
58   typedef SmartPointer<const Self>                          ConstPointer;
59
60   /** Method for creation through the object factory. */
61   itkNewMacro(Self);
62
63   /** Run-time type information (and related methods). */
64   itkTypeMacro(MeanSquaresImageToImageMetricFor3DBLUTFFD, ImageToImageMetric);
65
66   /** Types inherited from Superclass. */
67   typedef typename Superclass::TransformType            TransformType;
68   typedef typename Superclass::TransformPointer         TransformPointer;
69   typedef typename Superclass::TransformJacobianType    TransformJacobianType;
70   typedef typename Superclass::InterpolatorType         InterpolatorType;
71   typedef typename Superclass::MeasureType              MeasureType;
72   typedef typename Superclass::DerivativeType           DerivativeType;
73   typedef typename Superclass::ParametersType           ParametersType;
74   typedef typename Superclass::FixedImageType           FixedImageType;
75   typedef typename Superclass::MovingImageType          MovingImageType;
76   typedef typename Superclass::MovingImagePointType     MovingImagePointType;
77   typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
78   typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
79   typedef typename Superclass::CoordinateRepresentationType
80   CoordinateRepresentationType;
81   typedef typename Superclass::FixedImageSampleContainer
82   FixedImageSampleContainer;
83   typedef typename Superclass::ImageDerivativesType     ImageDerivativesType;
84   typedef typename Superclass::WeightsValueType         WeightsValueType;
85   typedef typename Superclass::IndexValueType           IndexValueType;
86
87   // Needed for evaluation of Jacobian.
88   typedef typename Superclass::FixedImagePointType     FixedImagePointType;
89
90   /** The moving image dimension. */
91   itkStaticConstMacro( MovingImageDimension, unsigned int,
92                        MovingImageType::ImageDimension );
93
94   /**
95    *  Initialize the Metric by
96    *  (1) making sure that all the components are present and plugged
97    *      together correctly,
98    *  (2) uniformly select NumberOfSpatialSamples within
99    *      the FixedImageRegion, and
100    *  (3) allocate memory for pdf data structures. */
101   virtual void Initialize(void) ITK_OVERRIDE;
102
103   /**  Get the value. */
104   MeasureType GetValue( const ParametersType & parameters ) const ITK_OVERRIDE;
105
106   /** Get the derivatives of the match measure. */
107   void GetDerivative( const ParametersType & parameters,
108                       DerivativeType & Derivative ) const ITK_OVERRIDE;
109
110   /**  Get the value and derivatives for single valued optimizers. */
111   void GetValueAndDerivative( const ParametersType & parameters,
112                               MeasureType & Value,
113                               DerivativeType & Derivative ) const ITK_OVERRIDE;
114
115 protected:
116
117   MeanSquaresImageToImageMetricFor3DBLUTFFD();
118   virtual ~MeanSquaresImageToImageMetricFor3DBLUTFFD();
119   void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
120
121 private:
122
123   //purposely not implemented
124   MeanSquaresImageToImageMetricFor3DBLUTFFD(const Self &);
125   //purposely not implemented
126   void operator=(const Self &);
127
128   inline bool GetValueThreadProcessSample( unsigned int threadID,
129       unsigned long fixedImageSample,
130       const MovingImagePointType & mappedPoint,
131       double movingImageValue ) const ITK_OVERRIDE;
132
133   inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID,
134       unsigned long fixedImageSample,
135       const MovingImagePointType & mappedPoint,
136       double movingImageValue,
137       const ImageDerivativesType &
138       movingImageGradientValue ) const ITK_OVERRIDE;
139
140   MeasureType    * m_ThreaderMSE;
141   DerivativeType * m_ThreaderMSEDerivatives;
142
143 };
144
145 } // end namespace itk
146
147 #ifndef ITK_MANUAL_INSTANTIATION
148 #include "itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx"
149 #endif
150
151 #endif