Orfeo Toolbox  4.2
itkVersorRigid3DTransformOptimizer.cxx
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef _itkVersorRigid3DTransformOptimizer_hxx
19 #define _itkVersorRigid3DTransformOptimizer_hxx
20 
22 
23 namespace itk
24 {
29 void
31 ::StepAlongGradient(double factor,
32  const DerivativeType & transformedGradient)
33 {
34  const ParametersType & currentPosition = this->GetCurrentPosition();
35 
36  // The parameters are assumed to be the right part of the versor and the
37  // components of the translation vector.
38  //
39  VectorType rightPart;
40 
41  for ( unsigned int i = 0; i < 3; i++ )
42  {
43  rightPart[i] = currentPosition[i];
44  }
45 
46  VersorType currentRotation;
47  currentRotation.Set(rightPart);
48 
49  // The gradient indicate the contribution of each one
50  // of the axis to the direction of highest change in
51  // the function
52  VectorType axis;
53  axis[0] = transformedGradient[0];
54  axis[1] = transformedGradient[1];
55  axis[2] = transformedGradient[2];
56 
57  // gradientRotation is a rotation along the
58  // versor direction which maximize the
59  // variation of the cost function in question.
60  // An additional Exponentiation produce a jump
61  // of a particular length along the versor gradient
62  // direction.
63 
64  VersorType gradientRotation;
65  gradientRotation.Set( axis, factor * axis.GetNorm() );
66 
67  //
68  // Composing the currentRotation with the gradientRotation
69  // produces the new Rotation versor
70  //
71  VersorType newRotation = currentRotation * gradientRotation;
72 
73  ParametersType newParameters(SpaceDimension);
74 
75  newParameters[0] = newRotation.GetX();
76  newParameters[1] = newRotation.GetY();
77  newParameters[2] = newRotation.GetZ();
78 
79  // Now do the typical update for a Vector space.
80  for ( unsigned int k = 3; k < 6; k++ )
81  {
82  newParameters[k] = currentPosition[k] + transformedGradient[k] * factor;
83  }
84 
85  this->SetCurrentPosition(newParameters);
86 }
87 } // end namespace itk
88 
89 #endif

Generated at Sat Aug 30 2014 15:49:18 for Orfeo Toolbox with doxygen 1.8.3.1