| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkScaleLogarithmicTransform.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:47 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 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 |
DEF |
#ifndef _itkScaleLogarithmicTransform_txx |
| 18 |
DEF |
#define _itkScaleLogarithmicTransform_txx |
| 19 |
|
|
| 20 |
|
#include "itkScaleLogarithmicTransform.h" |
| 21 |
|
|
| 22 |
|
|
| 23 |
|
namespace itk |
| 24 |
|
{ |
| 25 |
|
|
| 26 |
|
// Constructor with default arguments |
| 27 |
|
template<class ScalarType, unsigned int NDimensions> |
| 28 |
|
ScaleLogarithmicTransform<ScalarType, NDimensions>:: |
| 29 |
|
ScaleLogarithmicTransform() |
| 30 |
|
{ |
| 31 |
|
return; |
| 32 |
|
} |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
// Destructor |
| 37 |
|
template<class ScalarType, unsigned int NDimensions> |
| 38 |
|
ScaleLogarithmicTransform<ScalarType, NDimensions>:: |
| 39 |
|
~ScaleLogarithmicTransform() |
| 40 |
|
{ |
| 41 |
|
return; |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
// Set the parameters |
| 46 |
|
template <class ScalarType, unsigned int NDimensions> |
| 47 |
|
void |
| 48 |
|
ScaleLogarithmicTransform<ScalarType, NDimensions> |
| 49 |
|
::SetParameters( const ParametersType & parameters ) |
| 50 |
|
{ |
| 51 |
|
ScaleType scales; |
| 52 |
|
for( unsigned int i=0; i<SpaceDimension; i++ ) |
| 53 |
|
{ |
| 54 |
|
scales[i] = exp( parameters[i] ); |
| 55 |
|
} |
| 56 |
|
this->m_Parameters = parameters; |
| 57 |
|
this->SetScale( scales ); |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
// Get Parameters |
| 62 |
|
template <class TScalarType,unsigned int NDimensions> |
| 63 |
LEN |
const typename ScaleLogarithmicTransform<TScalarType,NDimensions>::ParametersType & |
| 64 |
|
ScaleLogarithmicTransform<TScalarType,NDimensions> |
| 65 |
|
::GetParameters( void ) const |
| 66 |
|
{ |
| 67 |
|
itkDebugMacro( << "Getting parameters "); |
| 68 |
|
|
| 69 |
|
const ScaleType & scales = this->GetScale(); |
| 70 |
|
// Transfer the translation part |
| 71 |
|
for(unsigned int i=0; i < SpaceDimension; i++) |
| 72 |
|
{ |
| 73 |
|
this->m_Parameters[i] = log( scales[i] ); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
itkDebugMacro(<<"After getting parameters " << this->m_Parameters ); |
| 77 |
|
|
| 78 |
|
return this->m_Parameters; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
EML |
|
| 83 |
|
// Print self |
| 84 |
|
template<class ScalarType, unsigned int NDimensions> |
| 85 |
|
void |
| 86 |
|
ScaleLogarithmicTransform<ScalarType, NDimensions>:: |
| 87 |
|
PrintSelf(std::ostream &os, Indent indent) const |
| 88 |
|
{ |
| 89 |
|
Superclass::PrintSelf(os, indent); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
// Compute the Jacobian of the transformation |
| 94 |
|
// It follows the same order of Parameters vector |
| 95 |
|
template<class ScalarType, unsigned int NDimensions> |
| 96 |
LEN |
const typename ScaleLogarithmicTransform<ScalarType, NDimensions>::JacobianType & |
| 97 |
|
ScaleLogarithmicTransform<ScalarType, NDimensions> |
| 98 |
|
::GetJacobian( const InputPointType & p ) const |
| 99 |
|
{ |
| 100 |
|
const ScaleType & scales = this->GetScale(); |
| 101 |
|
this->m_Jacobian.Fill(0); |
| 102 |
|
for(unsigned int dim=0; dim<SpaceDimension; dim++) |
| 103 |
|
{ |
| 104 |
LEN |
// the derivative with respect to Log(scale) = scale * derivative with respect to scale. |
| 105 |
|
this->m_Jacobian(dim,dim) = scales[dim] * p[dim]; |
| 106 |
|
} |
| 107 |
|
return this->m_Jacobian; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
} // namespace |
| 112 |
|
|
| 113 |
|
#endif |
| 114 |
|
|