Orfeo Toolbox  3.16
itkVersorRigid3DTransformOptimizer.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkVersorRigid3DTransformOptimizer.cxx,v $
5  Language: C++
6  Date: $Date: 2007-03-22 14:29:14 $
7  Version: $Revision: 1.2 $
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 _itkVersorRigid3DTransformOptimizer_txx
18 #define _itkVersorRigid3DTransformOptimizer_txx
19 
21 #include "vnl/vnl_quaternion.h"
22 #include "itkEventObject.h"
23 
24 namespace itk
25 {
26 
31 void
33 ::StepAlongGradient( double factor,
34  const DerivativeType & transformedGradient )
35 {
36 
37 
38  const ParametersType & currentPosition = this->GetCurrentPosition();
39 
40  // The parameters are assumed to be the right part of the versor and the
41  // components of the translation vector.
42  //
43  VectorType rightPart;
44  for(unsigned int i=0; i<3; i++)
45  {
46  rightPart[i] = currentPosition[i];
47  }
48 
49 
50  VersorType currentRotation;
51  currentRotation.Set( rightPart );
52 
53  // The gradient indicate the contribution of each one
54  // of the axis to the direction of highest change in
55  // the function
56  VectorType axis;
57  axis[0] = transformedGradient[0];
58  axis[1] = transformedGradient[1];
59  axis[2] = transformedGradient[2];
60 
61 
62  // gradientRotation is a rotation along the
63  // versor direction which maximize the
64  // variation of the cost function in question.
65  // An additional Exponentiation produce a jump
66  // of a particular length along the versor gradient
67  // direction.
68 
69  VersorType gradientRotation;
70  gradientRotation.Set( axis, factor * axis.GetNorm() );
71 
72  //
73  // Composing the currentRotation with the gradientRotation
74  // produces the new Rotation versor
75  //
76  VersorType newRotation = currentRotation * gradientRotation;
77 
78  ParametersType newParameters( SpaceDimension );
79 
80  newParameters[0] = newRotation.GetX();
81  newParameters[1] = newRotation.GetY();
82  newParameters[2] = newRotation.GetZ();
83 
84 
85  // Now do the typical update for a Vector space.
86  for(unsigned int k=3; k<6; k++)
87  {
88  newParameters[k] = currentPosition[k] + transformedGradient[k] * factor;
89  }
90 
91 
92  this->SetCurrentPosition( newParameters );
93 
94 }
95 
96 } // end namespace itk
97 
98 #endif

Generated at Sun Feb 3 2013 00:13:02 for Orfeo Toolbox with doxygen 1.8.1.1