Orfeo Toolbox  3.16
itkDemonsRegistrationFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkDemonsRegistrationFilter.txx,v $
5  Language: C++
6  Date: $Date: 2008-12-08 16:00:52 $
7  Version: $Revision: 1.14 $
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 __itkDemonsRegistrationFilter_txx
18 #define __itkDemonsRegistrationFilter_txx
20 
21 namespace itk
22 {
23 
27 template <class TFixedImage, class TMovingImage, class TDeformationField>
30 {
31 
33  drfp = DemonsRegistrationFunctionType::New();
34 
35  this->SetDifferenceFunction( static_cast<FiniteDifferenceFunctionType *>(
36  drfp.GetPointer() ) );
37 
38  m_UseMovingImageGradient = false;
39 
40 }
41 
42 
43 template <class TFixedImage, class TMovingImage, class TDeformationField>
44 void
46 ::PrintSelf(std::ostream& os, Indent indent) const
47 {
48  Superclass::PrintSelf( os, indent );
49  os << indent << "UseMovingImageGradient: ";
50  os << m_UseMovingImageGradient << std::endl;
51  os << indent << "Intensity difference threshold: " <<
52  this->GetIntensityDifferenceThreshold() << std::endl;
53 }
54 
55 
56 /*
57  * Set the function state values before each iteration
58  */
59 template <class TFixedImage, class TMovingImage, class TDeformationField>
60 void
63 {
64 
65  // call the superclass implementation
66  Superclass::InitializeIteration();
67 
68  // set the gradient selection flag
70  dynamic_cast<DemonsRegistrationFunctionType *>
71  (this->GetDifferenceFunction().GetPointer());
72 
73  if( !drfp )
74  {
75  itkExceptionMacro( <<
76  "Could not cast difference function to DemonsRegistrationFunction" );
77  }
78 
79  drfp->SetUseMovingImageGradient( m_UseMovingImageGradient );
80 
81 
85  if ( this->GetSmoothDeformationField() )
86  {
87  this->SmoothDeformationField();
88  }
89 
90 }
91 
92 
96 template <class TFixedImage, class TMovingImage, class TDeformationField>
97 double
99 ::GetMetric() const
100 {
101 
103  dynamic_cast<DemonsRegistrationFunctionType *>
104  (this->GetDifferenceFunction().GetPointer());
105 
106  if( !drfp )
107  {
108  itkExceptionMacro( <<
109  "Could not cast difference function to DemonsRegistrationFunction" );
110  }
111 
112  return drfp->GetMetric();
113 
114 }
115 
116 
120 template <class TFixedImage, class TMovingImage, class TDeformationField>
121 double
124 {
125 
127  dynamic_cast<DemonsRegistrationFunctionType *>
128  (this->GetDifferenceFunction().GetPointer());
129 
130  if( !drfp )
131  {
132  itkExceptionMacro( <<
133  "Could not cast difference function to DemonsRegistrationFunction" );
134  }
135 
136  return drfp->GetIntensityDifferenceThreshold();
137 
138 }
139 
143 template <class TFixedImage, class TMovingImage, class TDeformationField>
144 void
147 {
148 
150  dynamic_cast<DemonsRegistrationFunctionType *>
151  (this->GetDifferenceFunction().GetPointer());
152 
153  if( !drfp )
154  {
155  itkExceptionMacro( <<
156  "Could not cast difference function to DemonsRegistrationFunction" );
157  }
158 
159  drfp->SetIntensityDifferenceThreshold(threshold);
160 
161 }
162 
166 template <class TFixedImage, class TMovingImage, class TDeformationField>
167 void
170 {
171  // If we smooth the update buffer before applying it, then the are
172  // approximating a viscuous problem as opposed to an elastic problem
173  if ( this->GetSmoothUpdateField() )
174  {
175  this->SmoothUpdateField();
176  }
177 
178  this->Superclass::ApplyUpdate(dt);
179 
181  dynamic_cast<DemonsRegistrationFunctionType *>
182  (this->GetDifferenceFunction().GetPointer());
183 
184  if( !drfp )
185  {
186  itkExceptionMacro( <<
187  "Could not cast difference function to DemonsRegistrationFunction" );
188  }
189 
190  this->SetRMSChange( drfp->GetRMSChange() );
191 
192 }
193 
194 } // end namespace itk
195 
196 #endif

Generated at Sat May 18 2013 23:36:04 for Orfeo Toolbox with doxygen 1.8.3.1