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 #include "vnl/vnl_sample.h"
00033
00034 namespace itk
00035 {
00036
00062 template <class TScalarType,
00063 unsigned int NDimensions>
00064 class ITK_EXPORT KernelTransform :
00065 public Transform<TScalarType, NDimensions,NDimensions>
00066 {
00067 public:
00069 typedef KernelTransform Self;
00070 typedef Transform<TScalarType, NDimensions, NDimensions > Superclass;
00071 typedef SmartPointer<Self> Pointer;
00072 typedef SmartPointer<const Self> ConstPointer;
00073
00075 itkTypeMacro( KernelTransform, Transform );
00076
00078 itkNewMacro( Self );
00079
00081 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00082
00084 typedef typename Superclass::ScalarType ScalarType;
00085
00087 typedef typename Superclass::ParametersType ParametersType;
00088
00090 typedef typename Superclass::JacobianType JacobianType;
00091
00093 typedef typename Superclass::InputPointType InputPointType;
00094 typedef typename Superclass::OutputPointType OutputPointType;
00095
00097 typedef typename Superclass::InputVectorType InputVectorType;
00098 typedef typename Superclass::OutputVectorType OutputVectorType;
00099
00102 typedef DefaultStaticMeshTraits<TScalarType,
00103 NDimensions,
00104 NDimensions,
00105 TScalarType,
00106 TScalarType> PointSetTraitsType;
00107 typedef PointSet<InputPointType, NDimensions, PointSetTraitsType> PointSetType;
00108 typedef typename PointSetType::Pointer PointSetPointer;
00109 typedef typename PointSetType::PointsContainer PointsContainer;
00110 typedef typename PointSetType::PointsContainerIterator PointsIterator;
00111 typedef typename PointSetType::PointsContainerConstIterator PointsConstIterator;
00112
00114 typedef itk::VectorContainer<unsigned long,InputVectorType> VectorSetType;
00115 typedef typename VectorSetType::Pointer VectorSetPointer;
00116
00118 itkGetObjectMacro( SourceLandmarks, PointSetType);
00119
00121 virtual void SetSourceLandmarks(PointSetType *);
00122
00124 itkGetObjectMacro( TargetLandmarks, PointSetType);
00125
00127 virtual void SetTargetLandmarks(PointSetType *);
00128
00131 itkGetObjectMacro( Displacements, VectorSetType );
00132
00134 void ComputeWMatrix(void);
00135
00137 virtual OutputPointType TransformPoint(const InputPointType& thisPoint) const;
00138
00140 typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> IMatrixType;
00141
00142
00144 virtual const JacobianType & GetJacobian(const InputPointType &point ) const;
00145
00150 virtual void SetParameters(const ParametersType &);
00151
00157 virtual void SetFixedParameters(const ParametersType &);
00158
00160 virtual void UpdateParameters(void) const;
00161
00163 virtual const ParametersType& GetParameters(void) const;
00164
00166 virtual const ParametersType& GetFixedParameters(void) const;
00167
00178 itkSetClampMacro(Stiffness, double, 0.0, NumericTraits<double>::max());
00179 itkGetMacro(Stiffness, double);
00181
00182
00183 protected:
00184 KernelTransform();
00185 virtual ~KernelTransform();
00186 void PrintSelf(std::ostream& os, Indent indent) const;
00187
00188 public:
00190 typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> GMatrixType;
00191
00193 typedef vnl_matrix<TScalarType> LMatrixType;
00194
00196 typedef vnl_matrix<TScalarType> KMatrixType;
00197
00199 typedef vnl_matrix<TScalarType> PMatrixType;
00200
00202 typedef vnl_matrix<TScalarType> YMatrixType;
00203
00205 typedef vnl_matrix<TScalarType> WMatrixType;
00206
00208 typedef vnl_matrix<TScalarType> DMatrixType;
00209
00211 typedef vnl_matrix_fixed<TScalarType,NDimensions,NDimensions> AMatrixType;
00212
00214 typedef vnl_vector_fixed<TScalarType,NDimensions> BMatrixType;
00215
00217 typedef vnl_matrix_fixed<TScalarType, 1, NDimensions> RowMatrixType;
00218
00220 typedef vnl_matrix_fixed<TScalarType, NDimensions, 1> ColumnMatrixType;
00221
00223 PointSetPointer m_SourceLandmarks;
00224
00226 PointSetPointer m_TargetLandmarks;
00227
00228 protected:
00235 virtual const GMatrixType & ComputeG(const InputVectorType & landmarkVector) const;
00236
00243 virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
00244
00245
00248 virtual void ComputeDeformationContribution( const InputPointType & inputPoint,
00249 OutputPointType & result ) const;
00250
00252 void ComputeK();
00253
00255 void ComputeL();
00256
00258 void ComputeP();
00259
00261 void ComputeY();
00262
00264 void ComputeD();
00265
00270 void ReorganizeW(void);
00271
00273 double m_Stiffness;
00274
00277 VectorSetPointer m_Displacements;
00278
00280 LMatrixType m_LMatrix;
00281
00283 KMatrixType m_KMatrix;
00284
00286 PMatrixType m_PMatrix;
00287
00289 YMatrixType m_YMatrix;
00290
00292 WMatrixType m_WMatrix;
00293
00299 DMatrixType m_DMatrix;
00300
00302 AMatrixType m_AMatrix;
00303
00305 BMatrixType m_BVector;
00306
00310 mutable GMatrixType m_GMatrix;
00311
00313 bool m_WMatrixComputed;
00314
00316 IMatrixType m_I;
00317
00318 private:
00319 KernelTransform(const Self&);
00320 void operator=(const Self&);
00321
00322 };
00323
00324 }
00325
00326 #ifndef ITK_MANUAL_INSTANTIATION
00327 #include "itkKernelTransform.txx"
00328 #endif
00329
00330 #endif // __itkKernelTransform_h
00331