Orfeo Toolbox  3.16
itkSymmetricForcesDemonsRegistrationFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkSymmetricForcesDemonsRegistrationFilter.txx,v $
5  Language: C++
6  Date: $Date: 2009-01-27 19:30:16 $
7  Version: $Revision: 1.7 $
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 __itkSymmetricForcesDemonsRegistrationFilter_txx
18 #define __itkSymmetricForcesDemonsRegistrationFilter_txx
20 
21 namespace itk {
22 
26 template <class TFixedImage, class TMovingImage, class TDeformationField>
29 {
30 
32  drfp = DemonsRegistrationFunctionType::New();
33 
34  this->SetDifferenceFunction( static_cast<FiniteDifferenceFunctionType *>(
35  drfp.GetPointer() ) );
36 
37 }
38 
39 
40 /*
41  * Set the function state values before each iteration
42  */
43 template <class TFixedImage, class TMovingImage, class TDeformationField>
44 void
47 {
48 
49 
50  // update variables in the equation object
52  dynamic_cast<DemonsRegistrationFunctionType *>
53  (this->GetDifferenceFunction().GetPointer());
54 
55  if ( !f )
56  {
57  itkExceptionMacro(<<"FiniteDifferenceFunction not of type DemonsRegistrationFunctionType");
58  }
59 
60  f->SetDeformationField( this->GetDeformationField() );
61 
62 
63 
64  // call the superclass implementation
65  Superclass::InitializeIteration();
66 
67  /*
68  * Smooth the deformation field
69  */
70  if ( this->GetSmoothDeformationField() )
71  {
72  this->SmoothDeformationField();
73  }
74 
75 }
76 
77 
81 template <class TFixedImage, class TMovingImage, class TDeformationField>
82 double
84 ::GetMetric() const
85 {
86 
88  dynamic_cast<DemonsRegistrationFunctionType *>
89  (this->GetDifferenceFunction().GetPointer());
90 
91  if( !drfp )
92  {
93  itkExceptionMacro( <<
94  "Could not cast difference function to SymmetricForcesDemonsRegistrationFunction" );
95  }
96 
97  return drfp->GetMetric();
98 }
99 
100 /*
101  *
102  */
103 template <class TFixedImage, class TMovingImage, class TDeformationField>
104 double
107 {
108 
110  dynamic_cast<DemonsRegistrationFunctionType *>
111  (this->GetDifferenceFunction().GetPointer());
112 
113  if( !drfp )
114  {
115  itkExceptionMacro( <<
116  "Could not cast difference function to DemonsRegistrationFunction" );
117  }
118 
119  return drfp->GetIntensityDifferenceThreshold();
120 
121 }
122 
123 /*
124  *
125  */
126 template <class TFixedImage, class TMovingImage, class TDeformationField>
127 void
130 {
131 
133  dynamic_cast<DemonsRegistrationFunctionType *>
134  (this->GetDifferenceFunction().GetPointer());
135 
136  if( !drfp )
137  {
138  itkExceptionMacro( <<
139  "Could not cast difference function to SymmetricDemonsRegistrationFunction" );
140  }
141 
142  drfp->SetIntensityDifferenceThreshold(threshold);
143 
144 }
145 
146 /*
147  * Get the metric value from the difference function
148  */
149 template <class TFixedImage, class TMovingImage, class TDeformationField>
150 const double &
153 {
154 
156  dynamic_cast<DemonsRegistrationFunctionType *>
157  (this->GetDifferenceFunction().GetPointer());
158 
159  if( !drfp )
160  {
161  itkExceptionMacro( <<
162  "Could not cast difference function to SymmetricForcesDemonsRegistrationFunction" );
163  }
164 
165  return drfp->GetRMSChange();
166 
167 }
168 
169 
170 /*
171  * Get the metric value from the difference function
172  */
173 template <class TFixedImage, class TMovingImage, class TDeformationField>
174 void
177 {
178  // If we smooth the update buffer before applying it, then the are
179  // approximating a viscuous problem as opposed to an elastic problem
180  if ( this->GetSmoothUpdateField() )
181  {
182  this->SmoothUpdateField();
183  }
184 
185  this->Superclass::ApplyUpdate(dt);
186 
188  dynamic_cast<DemonsRegistrationFunctionType *>
189  (this->GetDifferenceFunction().GetPointer());
190 
191  if( !drfp )
192  {
193  itkExceptionMacro( <<
194  "Could not cast difference function to DemonsRegistrationFunction" );
195  }
196 
197  this->SetRMSChange( drfp->GetRMSChange() );
198 
199 }
200 
201 template <class TFixedImage, class TMovingImage, class TDeformationField>
202 void
204 ::PrintSelf(std::ostream& os, Indent indent) const
205 {
206  Superclass::PrintSelf( os, indent );
207  os << indent << "Intensity difference threshold: " <<
208  this->GetIntensityDifferenceThreshold() << std::endl;
209 }
210 
211 
212 } // end namespace itk
213 
214 #endif

Generated at Sun Feb 3 2013 00:09:25 for Orfeo Toolbox with doxygen 1.8.1.1