ANIMA  4.0
animaBaseOrientedModelImageToImageMetric.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkImageBase.h>
4 #include <itkTransform.h>
5 #include <itkInterpolateImageFunction.h>
6 #include <itkSingleValuedCostFunction.h>
7 #include <itkMacro.h>
8 #include <itkSpatialObject.h>
9 
10 namespace anima
11 {
12 template <class TFixedImage, class TMovingImage>
13 class BaseOrientedModelImageToImageMetric : public itk::SingleValuedCostFunction
14 {
15 public:
18  typedef itk::SingleValuedCostFunction Superclass;
19  typedef itk::SmartPointer<Self> Pointer;
20  typedef itk::SmartPointer<const Self> ConstPointer;
21 
23  typedef typename Superclass::ParametersValueType CoordinateRepresentationType;
24 
26  itkTypeMacro(BaseOrientedModelImageToImageMetric, SingleValuedCostFunction)
27 
28 
29  typedef TMovingImage MovingImageType;
30  typedef typename TMovingImage::PixelType MovingImagePixelType;
31  typedef typename MovingImageType::ConstPointer MovingImageConstPointer;
32 
34  typedef TFixedImage FixedImageType;
35  typedef typename FixedImageType::ConstPointer FixedImageConstPointer;
36  typedef typename FixedImageType::RegionType FixedImageRegionType;
37 
39  itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension);
40  itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension);
41 
43  typedef itk::Transform<CoordinateRepresentationType,
44  itkGetStaticConstMacro(MovingImageDimension),
45  itkGetStaticConstMacro(FixedImageDimension)>
47 
48  typedef typename TransformType::Pointer TransformPointer;
52  typedef typename TransformType::JacobianType TransformJacobianType;
53 
55  typedef itk::InterpolateImageFunction<
56  MovingImageType,
57  CoordinateRepresentationType > InterpolatorType;
58 
59  typedef typename InterpolatorType::Pointer InterpolatorPointer;
60 
63  typedef itk::SpatialObject< itkGetStaticConstMacro(FixedImageDimension) >
65  typedef typename FixedImageMaskType::Pointer FixedImageMaskPointer;
66  typedef typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer;
67 
68 
71  typedef itk::SpatialObject< itkGetStaticConstMacro(MovingImageDimension) >
73  typedef typename MovingImageMaskType::Pointer MovingImageMaskPointer;
74  typedef typename MovingImageMaskType::ConstPointer MovingImageMaskConstPointer;
75 
76  typedef double RealType;
77 
79  typedef typename Superclass::MeasureType MeasureType;
80 
82  typedef typename Superclass::DerivativeType DerivativeType;
83 
85  typedef typename Superclass::ParametersType ParametersType;
86 
88  itkSetConstObjectMacro( FixedImage, FixedImageType )
89 
91  itkGetConstObjectMacro( FixedImage, FixedImageType )
92 
94  itkSetConstObjectMacro( MovingImage, MovingImageType )
95 
97  itkGetConstObjectMacro( MovingImage, MovingImageType )
98 
100  itkSetObjectMacro( Transform, TransformType )
101 
103  itkGetConstObjectMacro( Transform, TransformType )
104 
106  itkSetObjectMacro( Interpolator, InterpolatorType )
107 
109  itkGetConstObjectMacro( Interpolator, InterpolatorType )
110 
112  itkGetConstReferenceMacro( NumberOfPixelsCounted, unsigned long )
113 
115  itkSetMacro( FixedImageRegion, FixedImageRegionType )
116 
118  itkGetConstReferenceMacro( FixedImageRegion, FixedImageRegionType )
119 
121  itkSetObjectMacro( MovingImageMask, MovingImageMaskType )
122  itkSetConstObjectMacro( MovingImageMask, MovingImageMaskType )
123  itkGetConstObjectMacro( MovingImageMask, MovingImageMaskType )
124 
126  itkSetObjectMacro( FixedImageMask, FixedImageMaskType )
127  itkSetConstObjectMacro( FixedImageMask, FixedImageMaskType )
128  itkGetConstObjectMacro( FixedImageMask, FixedImageMaskType )
129 
131  void SetTransformParameters( const ParametersType & parameters ) const;
132 
134  unsigned int GetNumberOfParameters(void) const ITK_OVERRIDE
135  { return m_Transform->GetNumberOfParameters(); }
136 
139  virtual void Initialize();
140 
142  void GetDerivative( const ParametersType & parameters,
143  DerivativeType & derivative ) const ITK_OVERRIDE
144  {
145  itkExceptionMacro("No derivatives implemented for tensor metrics...");
146  }
147 
149  MeasureType & value, DerivativeType & derivative) const ITK_OVERRIDE
150  {
151  itkExceptionMacro("No derivatives implemented for tensor metrics...");
152  }
153 
155  {
156  NONE = 0,
159  };
160 
161  itkSetMacro(ModelRotation, ModelReorientationType)
162  itkGetConstMacro(ModelRotation, ModelReorientationType)
163 
164 protected:
167  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
168 
169  mutable unsigned long m_NumberOfPixelsCounted;
170 
173 
175  mutable vnl_matrix <double> m_OrientationMatrix;
177 
180 
181 private:
182  BaseOrientedModelImageToImageMetric(const Self&); //purposely not implemented
183  void operator=(const Self&); //purposely not implemented
184 
185  FixedImageRegionType m_FixedImageRegion;
186 
187  ModelReorientationType m_ModelRotation;
188 };
189 
190 } // end of namespace anima
191 
void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE
void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const ITK_OVERRIDE
Should not be used.
itk::Transform< CoordinateRepresentationType, itkGetStaticConstMacro(MovingImageDimension), itkGetStaticConstMacro(FixedImageDimension)> TransformType
void SetTransformParameters(const ParametersType &parameters) const
void GetValueAndDerivative(const TransformParametersType &parameters, MeasureType &value, DerivativeType &derivative) const ITK_OVERRIDE