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: 2007-12-20 17:10:46 $
00007   Version:   $Revision: 1.46 $
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,
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 
00171   virtual bool IsLinear() const { return false; }
00172 
00183   itkSetClampMacro(Stiffness, double, 0.0, NumericTraits<double>::max());
00184   itkGetMacro(Stiffness, double);
00186 
00187 
00188 protected:
00189   KernelTransform();
00190   virtual ~KernelTransform();
00191   void PrintSelf(std::ostream& os, Indent indent) const;
00192 
00193 public:  
00195   typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> GMatrixType;
00196 
00198   typedef vnl_matrix<TScalarType> LMatrixType;
00199 
00201   typedef vnl_matrix<TScalarType> KMatrixType;
00202 
00204   typedef vnl_matrix<TScalarType> PMatrixType;
00205 
00207   typedef vnl_matrix<TScalarType> YMatrixType;
00208 
00210   typedef vnl_matrix<TScalarType> WMatrixType;
00211 
00213   typedef vnl_matrix<TScalarType> DMatrixType;
00214 
00216   typedef vnl_matrix_fixed<TScalarType,NDimensions,NDimensions> AMatrixType;
00217 
00219   typedef vnl_vector_fixed<TScalarType,NDimensions> BMatrixType;
00220 
00222   typedef vnl_matrix_fixed<TScalarType, 1, NDimensions> RowMatrixType;
00223 
00225   typedef vnl_matrix_fixed<TScalarType, NDimensions, 1> ColumnMatrixType;
00226 
00227  
00228 protected:
00235   virtual void ComputeG(const InputVectorType& landmarkVector, GMatrixType & gmatrix ) const;
00236 
00240   itkLegacyMacro( virtual const GMatrixType & ComputeG(const InputVectorType& landmarkVector) const );
00241 
00242 
00252   virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
00253 
00254   
00257   virtual void ComputeDeformationContribution( const InputPointType & inputPoint,
00258                                                      OutputPointType & result ) const;
00259 
00261   void ComputeK();
00262 
00264   void ComputeL();
00265 
00267   void ComputeP();
00268 
00270   void ComputeY();
00271 
00273   void ComputeD();
00274 
00279   void ReorganizeW(void);
00280 
00282   double m_Stiffness;
00283 
00286   VectorSetPointer m_Displacements;
00287 
00289   LMatrixType m_LMatrix;
00290 
00292   KMatrixType m_KMatrix;
00293 
00295   PMatrixType m_PMatrix;
00296 
00298   YMatrixType m_YMatrix;
00299 
00301   WMatrixType m_WMatrix;
00302 
00308   DMatrixType m_DMatrix;
00309 
00311   AMatrixType m_AMatrix;
00312 
00314   BMatrixType m_BVector;
00315 
00319   mutable GMatrixType m_GMatrix;
00320 
00322   bool m_WMatrixComputed;
00323 
00325   IMatrixType m_I;
00326 
00328   PointSetPointer m_SourceLandmarks;
00329 
00331   PointSetPointer m_TargetLandmarks;
00332 
00333  private:
00334   KernelTransform(const Self&); //purposely not implemented
00335   void operator=(const Self&); //purposely not implemented
00336 
00337 };
00338 
00339 } // end namespace itk
00340 
00341 // Define instantiation macro for this template.
00342 #define ITK_TEMPLATE_KernelTransform(_, EXPORT, x, y) namespace itk { \
00343   _(2(class EXPORT KernelTransform< ITK_TEMPLATE_2 x >)) \
00344   namespace Templates { typedef KernelTransform< ITK_TEMPLATE_2 x > \
00345                                                   KernelTransform##y; } \
00346   }
00347 
00348 #if ITK_TEMPLATE_EXPLICIT
00349 # include "Templates/itkKernelTransform+-.h"
00350 #endif
00351 
00352 #if ITK_TEMPLATE_TXX
00353 # include "itkKernelTransform.txx"
00354 #endif
00355 
00356 #endif // __itkKernelTransform_h
00357 

Generated at Tue Jul 29 21:00:29 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000