Orfeo Toolbox  3.16
itkFEMFiniteDifferenceFunctionLoad.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFEMFiniteDifferenceFunctionLoad.h,v $
5  Language: C++
6  Date: $Date: 2009-05-12 17:26:20 $
7  Version: $Revision: 1.6 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkFEMFiniteDifferenceFunctionLoad_h
18 #define __itkFEMFiniteDifferenceFunctionLoad_h
19 
20 #include "itkFEMLoadElementBase.h"
21 
22 #include "itkImage.h"
24 
29 #include "itkDerivativeOperator.h"
32 #include "vnl/vnl_math.h"
33 
38 
39 namespace itk
40 {
41 namespace fem
42 {
43 
63 template<class TMoving,class TFixed>
65 {
67 public:
68 
69  // Necessary typedefs for dealing with images BEGIN
70  typedef typename LoadElement::Float Float;
71 
72  typedef TMoving MovingImageType;
73  typedef typename MovingImageType::ConstPointer MovingConstPointer;
74  typedef MovingImageType* MovingPointer;
75  typedef TFixed FixedImageType;
76  typedef FixedImageType* FixedPointer;
77  typedef typename FixedImageType::ConstPointer FixedConstPointer;
78 
80  itkStaticConstMacro(ImageDimension, unsigned int,
81  MovingImageType::ImageDimension);
82 
85 
86 
87  typedef NeighborhoodIterator<MovingImageType>
89  typedef typename MovingNeighborhoodIteratorType::IndexType
95  typedef NeighborhoodIterator<FixedImageType>
97  typedef typename FixedNeighborhoodIteratorType::IndexType
99  typedef typename FixedNeighborhoodIteratorType::RadiusType
101 
102 
103 // IMAGE DATA
104  typedef typename MovingImageType::PixelType MovingPixelType;
105  typedef typename FixedImageType::PixelType FixedPixelType;
106  typedef Float PixelType;
107  typedef Float ComputationType;
108  typedef Image< PixelType, itkGetStaticConstMacro(ImageDimension) >
110  typedef itk::Vector<float,itkGetStaticConstMacro(ImageDimension)>
112  typedef vnl_vector<Float> FEMVectorType;
113  typedef Image< VectorType, itkGetStaticConstMacro(ImageDimension) >
116 
117 
120 
121 // Necessary typedefs for dealing with images END
122 
124  typedef PDEDeformableRegistrationFunction<FixedImageType,MovingImageType,
126  typedef typename FiniteDifferenceFunctionType::Pointer FiniteDifferenceFunctionTypePointer;
127 
128 
129  typedef typename FiniteDifferenceFunctionType::TimeStepType TimeStepType;
130 
131  typedef MeanSquareRegistrationFunction<FixedImageType,MovingImageType,
133 
134  typedef DemonsRegistrationFunction<FixedImageType,MovingImageType,
136 
137  typedef NCCRegistrationFunction<FixedImageType,MovingImageType,
139 
140  typedef MIRegistrationFunction<FixedImageType,MovingImageType,
142 
143 // FUNCTIONS
144 
145  /* This method sets the pointer to a FiniteDifferenceFunction object that
146  * will be used by the filter to calculate updates at image pixels.
147  * \returns A FiniteDifferenceObject pointer. */
148  void SetDifferenceFunction( FiniteDifferenceFunctionTypePointer drfp)
149  {
150  drfp->SetFixedImage(m_FixedImage);
151  drfp->SetMovingImage(m_MovingImage);
152  drfp->SetRadius(m_MetricRadius);
153  drfp->SetDeformationField(m_DeformationField);
154  drfp->InitializeIteration();
155  this->m_DifferenceFunction=drfp;
156  }
157 
158  void SetMetric( FiniteDifferenceFunctionTypePointer drfp )
159  {
160  this->SetDifferenceFunction( static_cast<FiniteDifferenceFunctionType *>(
161  drfp.GetPointer() ) );
162 
163  m_FixedSize=m_DeformationField->GetLargestPossibleRegion().GetSize();
164  }
165 
167  void SetMovingImage(MovingImageType* R)
168  {
169  m_MovingImage = R;
170  m_MovingSize=m_MovingImage->GetLargestPossibleRegion().GetSize();
171  if (this->m_DifferenceFunction) this->m_DifferenceFunction->SetMovingImage(m_MovingImage);
172  };
173 
174 
176  void SetFixedImage(FixedImageType* T)
177  {
178  m_FixedImage=T;
179  m_FixedSize=T->GetLargestPossibleRegion().GetSize();
180  if (this->m_DifferenceFunction)
181  {
182  this->m_DifferenceFunction->SetFixedImage(m_MovingImage);
183  }
184  }
185 
186  MovingPointer GetMovingImage()
187  {
188  return m_MovingImage;
189  }
190 
191  FixedPointer GetFixedImage()
192  {
193  return m_FixedImage;
194  }
195 
197  void SetMetricRadius(MovingRadiusType T)
198  {
199  m_MetricRadius = T;
200  }
202  MovingRadiusType GetMetricRadius()
203  {
204  return m_MetricRadius;
205  }
206 
211  void SetNumberOfIntegrationPoints(unsigned int i)
212  {
213  m_NumberOfIntegrationPoints=i;
214  }
215  unsigned int GetNumberOfIntegrationPoints()
216  {
217  return m_NumberOfIntegrationPoints;
218  }
219 
223  void SetSign(Float s)
224  {
225  m_Sign=s;
226  }
227 
229  void SetTemp(Float s)
230  {
231  m_Temp=s;
232  }
233 
234 
236  void SetGamma(Float s)
237  {
238  m_Gamma=s;
239  }
240 
241  void SetSolution(Solution::ConstPointer ptr)
242  {
243  m_Solution=ptr;
244  }
246  {
247  return m_Solution;
248  }
249 
250  // FIXME - WE ASSUME THE 2ND VECTOR (INDEX 1) HAS THE INFORMATION WE WANT
251  Float GetSolution(unsigned int i,unsigned int which=0)
252  {
253  return m_Solution->GetSolutionValue(i,which);
254  }
255 
256  FiniteDifferenceFunctionLoad(); // cannot be private until we always use smart pointers
257  Float EvaluateMetricGivenSolution ( Element::ArrayType* el, Float step=1.0);
258 
262  VectorType Fe1(VectorType);
263  FEMVectorType Fe(FEMVectorType,FEMVectorType);
264 
265  static Baseclass* NewFiniteDifferenceFunctionLoad(void)
266  { return new FiniteDifferenceFunctionLoad; }
267 
268 
270  void SetDeformationField( DeformationFieldTypePointer df)
271  { m_DeformationField=df;}
272 
274  DeformationFieldTypePointer GetDeformationField() { return m_DeformationField;}
275  void InitializeIteration();
276  void InitializeMetric();
277 
278  void PrintCurrentEnergy();
279  double GetCurrentEnergy();
280  void SetCurrentEnergy( double e = 0.0);
281 
282 protected:
283 
284 
285 private:
289  typename MovingImageType::SizeType m_MovingSize;
290  typename FixedImageType::SizeType m_FixedSize;
292  unsigned int m_SolutionIndex;
293  unsigned int m_SolutionIndex2;
297 
298  float m_GradSigma;
299  float m_Sign;
302 
306  static const int m_DummyCLID;
307 
308 };
309 
310 }
311 } // end namespace fem/itk
312 
313 #ifndef ITK_MANUAL_INSTANTIATION
315 #endif
316 
317 #endif

Generated at Sat May 18 2013 23:37:56 for Orfeo Toolbox with doxygen 1.8.3.1