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
00054 template <class TScalarType,
00055 unsigned int NDimensions>
00056 class ITK_EXPORT KernelTransform :
00057 public Transform<TScalarType, NDimensions,NDimensions>
00058 {
00059 public:
00061 typedef KernelTransform Self;
00062 typedef Transform<TScalarType, NDimensions, NDimensions > Superclass;
00063 typedef SmartPointer<Self> Pointer;
00064 typedef SmartPointer<const Self> ConstPointer;
00065
00067 itkTypeMacro( KernelTransform, Transform );
00068
00070 itkNewMacro( Self );
00071
00073 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00074
00076 typedef typename Superclass::ScalarType ScalarType;
00077
00079 typedef typename Superclass::ParametersType ParametersType;
00080
00082 typedef typename Superclass::JacobianType JacobianType;
00083
00085 typedef typename Superclass::InputPointType InputPointType;
00086 typedef typename Superclass::OutputPointType OutputPointType;
00087
00089 typedef typename Superclass::InputVectorType InputVectorType;
00090 typedef typename Superclass::OutputVectorType OutputVectorType;
00091
00094 typedef DefaultStaticMeshTraits<TScalarType,
00095 NDimensions,
00096 NDimensions,
00097 TScalarType,
00098 TScalarType> PointSetTraitsType;
00099 typedef PointSet<InputPointType, NDimensions, PointSetTraitsType> PointSetType;
00100 typedef typename PointSetType::Pointer PointSetPointer;
00101 typedef typename PointSetType::PointsContainer PointsContainer;
00102 typedef typename PointSetType::PointsContainerIterator PointsIterator;
00103 typedef typename PointSetType::PointsContainerConstIterator PointsConstIterator;
00104
00106 typedef itk::VectorContainer<unsigned long,InputVectorType> VectorSetType;
00107 typedef typename VectorSetType::Pointer VectorSetPointer;
00108
00110 itkGetObjectMacro( SourceLandmarks, PointSetType );
00111
00113 itkSetObjectMacro( SourceLandmarks, PointSetType );
00114
00116 itkGetObjectMacro( TargetLandmarks, PointSetType );
00117
00119 itkSetObjectMacro( TargetLandmarks, PointSetType );
00120
00123 itkGetObjectMacro( Displacements, VectorSetType );
00124
00126 void ComputeWMatrix(void);
00127
00129 virtual OutputPointType TransformPoint(const InputPointType& thisPoint) const;
00130
00132 typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> IMatrixType;
00133
00134
00136 virtual const JacobianType & GetJacobian(const InputPointType &point ) const;
00137
00140 virtual void SetParameters(const ParametersType &);
00141
00143 virtual const ParametersType& GetParameters(void) const;
00144
00145
00146 protected:
00147 KernelTransform();
00148 virtual ~KernelTransform();
00149 void PrintSelf(std::ostream& os, Indent indent) const;
00150
00152 typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> GMatrixType;
00153
00155 typedef vnl_matrix<TScalarType> LMatrixType;
00156
00158 typedef vnl_matrix<TScalarType> KMatrixType;
00159
00161 typedef vnl_matrix<TScalarType> PMatrixType;
00162
00164 typedef vnl_matrix<TScalarType> YMatrixType;
00165
00167 typedef vnl_matrix<TScalarType> WMatrixType;
00168
00170 typedef vnl_matrix<TScalarType> DMatrixType;
00171
00173 typedef vnl_matrix_fixed<TScalarType,NDimensions,NDimensions> AMatrixType;
00174
00176 typedef vnl_vector_fixed<TScalarType,NDimensions> BMatrixType;
00177
00179 typedef vnl_matrix_fixed<TScalarType, 1, NDimensions> RowMatrixType;
00180
00182 typedef vnl_matrix_fixed<TScalarType, NDimensions, 1> ColumnMatrixType;
00183
00190 virtual const GMatrixType & ComputeG(const InputVectorType & landmarkVector) const;
00191
00194 virtual void ComputeDeformationContribution( const InputPointType & inputPoint,
00195 OutputPointType & result ) const;
00196
00198 void ComputeK();
00199
00201 void ComputeL();
00202
00204 void ComputeP();
00205
00207 void ComputeY();
00208
00210 void ComputeD();
00211
00216 void ReorganizeW(void);
00217
00219 PointSetPointer m_SourceLandmarks;
00220
00222 PointSetPointer m_TargetLandmarks;
00223
00226 VectorSetPointer m_Displacements;
00227
00229 LMatrixType m_LMatrix;
00230
00232 KMatrixType m_KMatrix;
00233
00235 PMatrixType m_PMatrix;
00236
00238 YMatrixType m_YMatrix;
00239
00241 WMatrixType m_WMatrix;
00242
00248 DMatrixType m_DMatrix;
00249
00251 AMatrixType m_AMatrix;
00252
00254 BMatrixType m_BVector;
00255
00259 mutable GMatrixType m_GMatrix;
00260
00262 bool m_WMatrixComputed;
00263
00265 IMatrixType m_I;
00266
00267 private:
00268 KernelTransform(const Self&);
00269 void operator=(const Self&);
00270
00271 };
00272
00273 }
00274
00275 #ifndef ITK_MANUAL_INSTANTIATION
00276 #include "itkKernelTransform.txx"
00277 #endif
00278
00279 #endif // __itkKernelTransform_h