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