Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkKernelTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkKernelTransform.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-17 14:27:01 $
00007   Version:   $Revision: 1.49 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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, // probably only float and double make sense here
00063           unsigned int NDimensions>   // Number of dimensions
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, NDimensions,
00103                                   NDimensions, TScalarType,
00104                                   TScalarType>          PointSetTraitsType;
00105   typedef PointSet<InputPointType, NDimensions, PointSetTraitsType> 
00106                                                         PointSetType;
00107   typedef typename PointSetType::Pointer                PointSetPointer;
00108   typedef typename PointSetType::PointsContainer        PointsContainer;
00109   typedef typename PointSetType::PointsContainerIterator 
00110                                                         PointsIterator;
00111   typedef typename PointSetType::PointsContainerConstIterator
00112                                                         PointsConstIterator;
00113 
00115   typedef itk::VectorContainer<unsigned long,InputVectorType> VectorSetType;
00116   typedef typename VectorSetType::Pointer                     VectorSetPointer;
00117 
00119   itkGetObjectMacro( SourceLandmarks, PointSetType);
00120 
00122   virtual void SetSourceLandmarks(PointSetType *);
00123 
00125   itkGetObjectMacro( TargetLandmarks, PointSetType);
00126 
00128   virtual void SetTargetLandmarks(PointSetType *);
00129 
00132   itkGetObjectMacro( Displacements, VectorSetType );
00133 
00135   void ComputeWMatrix(void);
00136 
00138   virtual OutputPointType TransformPoint(const InputPointType& thisPoint) const;
00139 
00141   typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> IMatrixType;
00142 
00143 
00145   virtual const JacobianType & GetJacobian(const InputPointType  &point) const;
00146 
00151   virtual void SetParameters(const ParametersType &);
00152 
00158   virtual void SetFixedParameters(const ParametersType &);
00159 
00161   virtual void UpdateParameters(void) const;
00162 
00164   virtual const ParametersType& GetParameters(void) const;
00165 
00167   virtual const ParametersType& GetFixedParameters(void) const;
00168 
00172   virtual bool IsLinear() const { return false; }
00173 
00184   itkSetClampMacro(Stiffness, double, 0.0, NumericTraits<double>::max());
00185   itkGetConstMacro(Stiffness, double);
00187 
00188 
00189 protected:
00190   KernelTransform();
00191   virtual ~KernelTransform();
00192   void PrintSelf(std::ostream& os, Indent indent) const;
00193 
00194 public:  
00196   typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> GMatrixType;
00197 
00199   typedef vnl_matrix<TScalarType> LMatrixType;
00200 
00202   typedef vnl_matrix<TScalarType> KMatrixType;
00203 
00205   typedef vnl_matrix<TScalarType> PMatrixType;
00206 
00208   typedef vnl_matrix<TScalarType> YMatrixType;
00209 
00211   typedef vnl_matrix<TScalarType> WMatrixType;
00212 
00214   typedef vnl_matrix<TScalarType> DMatrixType;
00215 
00217   typedef vnl_matrix_fixed<TScalarType,NDimensions,NDimensions> AMatrixType;
00218 
00220   typedef vnl_vector_fixed<TScalarType,NDimensions> BMatrixType;
00221 
00223   typedef vnl_matrix_fixed<TScalarType, 1, NDimensions> RowMatrixType;
00224 
00226   typedef vnl_matrix_fixed<TScalarType, NDimensions, 1> ColumnMatrixType;
00227 
00228  
00229 protected:
00236   virtual void ComputeG(const InputVectorType& landmarkVector, 
00237                         GMatrixType & gmatrix ) const;
00238 
00242   itkLegacyMacro( virtual const GMatrixType & ComputeG(
00243                                   const InputVectorType & landmarkVector 
00244                                   ) const );
00245 
00246 
00256   virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
00257 
00258   
00261   virtual void ComputeDeformationContribution( 
00262                                           const InputPointType & inputPoint,
00263                                           OutputPointType & result ) const;
00264 
00266   void ComputeK();
00267 
00269   void ComputeL();
00270 
00272   void ComputeP();
00273 
00275   void ComputeY();
00276 
00278   void ComputeD();
00279 
00284   void ReorganizeW(void);
00285 
00287   double m_Stiffness;
00288 
00291   VectorSetPointer m_Displacements;
00292 
00294   LMatrixType m_LMatrix;
00295 
00297   KMatrixType m_KMatrix;
00298 
00300   PMatrixType m_PMatrix;
00301 
00303   YMatrixType m_YMatrix;
00304 
00306   WMatrixType m_WMatrix;
00307 
00313   DMatrixType m_DMatrix;
00314 
00316   AMatrixType m_AMatrix;
00317 
00319   BMatrixType m_BVector;
00320 
00324   mutable GMatrixType m_GMatrix;
00325 
00327   bool m_WMatrixComputed;
00328 
00330   IMatrixType m_I;
00331 
00333   PointSetPointer m_SourceLandmarks;
00334 
00336   PointSetPointer m_TargetLandmarks;
00337 
00338 private:
00339   KernelTransform(const Self&); //purposely not implemented
00340   void operator=(const Self&); //purposely not implemented
00341 
00342 };
00343 
00344 } // end namespace itk
00345 
00346 // Define instantiation macro for this template.
00347 #define ITK_TEMPLATE_KernelTransform(_, EXPORT, x, y) namespace itk { \
00348   _(2(class EXPORT KernelTransform< ITK_TEMPLATE_2 x >)) \
00349   namespace Templates { typedef KernelTransform< ITK_TEMPLATE_2 x > \
00350                                                   KernelTransform##y; } \
00351   }
00352 
00353 #if ITK_TEMPLATE_EXPLICIT
00354 # include "Templates/itkKernelTransform+-.h"
00355 #endif
00356 
00357 #if ITK_TEMPLATE_TXX
00358 # include "itkKernelTransform.txx"
00359 #endif
00360 
00361 #endif // __itkKernelTransform_h
00362 

Generated at Tue Sep 15 03:40:53 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000