00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkKernelTransform_h
00018
#define __itkKernelTransform_h
00019
00020
#include "itkTransform.h"
00021
#include "itkPoint.h"
00022
#include "itkVector.h"
00023
#include "itkMatrix.h"
00024
#include "itkPointSet.h"
00025
#include <deque>
00026
#include <math.h>
00027
#include "vnl/vnl_matrix_fixed.h"
00028
#include "vnl/vnl_matrix.h"
00029
#include "vnl/vnl_vector.h"
00030
#include "vnl/vnl_vector_fixed.h"
00031
#include "vnl/algo/vnl_svd.h"
00032
00033
namespace itk
00034 {
00035
00061
template <
class TScalarType,
00062
unsigned int NDimensions>
00063 class ITK_EXPORT KernelTransform :
00064
public Transform<TScalarType, NDimensions,NDimensions>
00065 {
00066
public:
00068 typedef KernelTransform
Self;
00069 typedef Transform<TScalarType, NDimensions, NDimensions > Superclass;
00070 typedef SmartPointer<Self> Pointer;
00071 typedef SmartPointer<const Self> ConstPointer;
00072
00074
itkTypeMacro( KernelTransform,
Transform );
00075
00077
itkNewMacro(
Self );
00078
00080
itkStaticConstMacro(SpaceDimension,
unsigned int, NDimensions);
00081
00083 typedef typename Superclass::ScalarType
ScalarType;
00084
00086 typedef typename Superclass::ParametersType
ParametersType;
00087
00089 typedef typename Superclass::JacobianType
JacobianType;
00090
00092 typedef typename Superclass::InputPointType
InputPointType;
00093 typedef typename Superclass::OutputPointType
OutputPointType;
00094
00096 typedef typename Superclass::InputVectorType
InputVectorType;
00097 typedef typename Superclass::OutputVectorType
OutputVectorType;
00098
00101
typedef DefaultStaticMeshTraits<TScalarType,
00102 NDimensions,
00103 NDimensions,
00104 TScalarType,
00105 TScalarType>
PointSetTraitsType;
00106 typedef PointSet<InputPointType, NDimensions, PointSetTraitsType> PointSetType;
00107 typedef typename PointSetType::Pointer
PointSetPointer;
00108 typedef typename PointSetType::PointsContainer
PointsContainer;
00109 typedef typename PointSetType::PointsContainerIterator
PointsIterator;
00110 typedef typename PointSetType::PointsContainerConstIterator
PointsConstIterator;
00111
00113 typedef itk::VectorContainer<unsigned long,InputVectorType> VectorSetType;
00114 typedef typename VectorSetType::Pointer
VectorSetPointer;
00115
00117
itkGetObjectMacro( SourceLandmarks,
PointSetType );
00118
00120
itkSetObjectMacro( SourceLandmarks,
PointSetType );
00121
00123
itkGetObjectMacro( TargetLandmarks,
PointSetType );
00124
00126
itkSetObjectMacro( TargetLandmarks,
PointSetType );
00127
00130
itkGetObjectMacro( Displacements,
VectorSetType );
00131
00133
void ComputeWMatrix(
void);
00134
00136
virtual OutputPointType TransformPoint(
const InputPointType& thisPoint)
const;
00137
00139 typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions>
IMatrixType;
00140
00141
00143
virtual const JacobianType & GetJacobian(
const InputPointType &point )
const;
00144
00149
virtual void SetParameters(
const ParametersType &);
00150
00152
virtual const ParametersType& GetParameters(
void) const;
00153
00164 itkSetClampMacro(Stiffness,
double, 0.0,
NumericTraits<
double>::max());
00165 itkGetMacro(Stiffness,
double);
00166
00167
00168 protected:
00169 KernelTransform();
00170 virtual ~KernelTransform();
00171
void PrintSelf(std::ostream& os,
Indent indent) const;
00172
00173 public:
00175 typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions>
GMatrixType;
00176
00178 typedef
vnl_matrix<TScalarType>
LMatrixType;
00179
00181 typedef
vnl_matrix<TScalarType>
KMatrixType;
00182
00184 typedef
vnl_matrix<TScalarType>
PMatrixType;
00185
00187 typedef
vnl_matrix<TScalarType>
YMatrixType;
00188
00190 typedef
vnl_matrix<TScalarType>
WMatrixType;
00191
00193 typedef
vnl_matrix<TScalarType>
DMatrixType;
00194
00196 typedef vnl_matrix_fixed<TScalarType,NDimensions,NDimensions>
AMatrixType;
00197
00199 typedef vnl_vector_fixed<TScalarType,NDimensions>
BMatrixType;
00200
00202 typedef vnl_matrix_fixed<TScalarType, 1, NDimensions>
RowMatrixType;
00203
00205 typedef vnl_matrix_fixed<TScalarType, NDimensions, 1>
ColumnMatrixType;
00206
00207 protected:
00214 virtual const GMatrixType & ComputeG(const
InputVectorType & landmarkVector) const;
00215
00222 virtual const GMatrixType & ComputeReflexiveG(
PointsIterator) const;
00223
00224
00227 virtual
void ComputeDeformationContribution( const
InputPointType & inputPoint,
00228
OutputPointType & result ) const;
00229
00231
void ComputeK();
00232
00234
void ComputeL();
00235
00237
void ComputeP();
00238
00240
void ComputeY();
00241
00243
void ComputeD();
00244
00249
void ReorganizeW(
void);
00250
00252
PointSetPointer m_SourceLandmarks;
00253
00255
PointSetPointer m_TargetLandmarks;
00256
00258
double m_Stiffness;
00259
00262
VectorSetPointer m_Displacements;
00263
00265 LMatrixType m_LMatrix;
00266
00268 KMatrixType m_KMatrix;
00269
00271 PMatrixType m_PMatrix;
00272
00274 YMatrixType m_YMatrix;
00275
00277 WMatrixType m_WMatrix;
00278
00284 DMatrixType m_DMatrix;
00285
00287 AMatrixType m_AMatrix;
00288
00290 BMatrixType m_BVector;
00291
00295 mutable GMatrixType m_GMatrix;
00296
00298
bool m_WMatrixComputed;
00299
00301
IMatrixType m_I;
00302
00303 private:
00304 KernelTransform(const
Self&);
00305
void operator=(const Self&);
00306
00307 };
00308
00309 }
00310
00311 #ifndef ITK_MANUAL_INSTANTIATION
00312 #include "itkKernelTransform.txx"
00313 #endif
00314
00315 #endif