go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkKernelTransform2.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Insight Segmentation & Registration Toolkit
00004 Module:    $RCSfile: itkKernelTransform2.h,v $
00005 Language:  C++
00006 Date:      $Date: 2006-11-28 14:22:18 $
00007 Version:   $Revision: 1.1 $
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 __itkKernelTransform2_h
00018 #define __itkKernelTransform2_h
00019 
00020 #include "itkAdvancedTransform.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 
00073 template <class TScalarType, // probably only float and double make sense here
00074   unsigned int NDimensions>   // Number of dimensions
00075 class KernelTransform2
00076   : public AdvancedTransform<TScalarType, NDimensions,NDimensions>
00077 {
00078 public:
00079 
00081   typedef KernelTransform2                  Self;
00082   typedef AdvancedTransform<
00083     TScalarType, NDimensions, NDimensions > Superclass;
00084   typedef SmartPointer<Self>                Pointer;
00085   typedef SmartPointer<const Self>          ConstPointer;
00086 
00088   itkTypeMacro( KernelTransform2, AdvancedTransform );
00089 
00091   itkNewMacro( Self );
00092 
00094   itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00095 
00097   typedef typename Superclass::ScalarType       ScalarType;
00098   typedef typename Superclass::ParametersType   ParametersType;
00099   typedef typename Superclass::JacobianType     JacobianType;
00100   typedef typename Superclass::InputPointType   InputPointType;
00101   typedef typename Superclass::OutputPointType  OutputPointType;
00102   typedef typename Superclass::InputVectorType  InputVectorType;
00103   typedef typename Superclass::OutputVectorType OutputVectorType;
00104 
00106   typedef typename Superclass
00107     ::NonZeroJacobianIndicesType                    NonZeroJacobianIndicesType;
00108   typedef typename Superclass::SpatialJacobianType  SpatialJacobianType;
00109   typedef typename Superclass
00110     ::JacobianOfSpatialJacobianType                 JacobianOfSpatialJacobianType;
00111   typedef typename Superclass::SpatialHessianType   SpatialHessianType;
00112   typedef typename Superclass
00113     ::JacobianOfSpatialHessianType                  JacobianOfSpatialHessianType;
00114   typedef typename Superclass::InternalMatrixType   InternalMatrixType;
00115 
00119   typedef DefaultStaticMeshTraits< TScalarType,
00120     NDimensions, NDimensions, TScalarType, TScalarType>       PointSetTraitsType;
00121   typedef PointSet<InputPointType, NDimensions,
00122     PointSetTraitsType>                                       PointSetType;
00123   typedef typename PointSetType::Pointer                      PointSetPointer;
00124   typedef typename PointSetType::PointsContainer              PointsContainer;
00125   typedef typename PointSetType::PointsContainerIterator      PointsIterator;
00126   typedef typename PointSetType::PointsContainerConstIterator PointsConstIterator;
00127 
00129   typedef VectorContainer<unsigned long,InputVectorType>      VectorSetType;
00130   typedef typename VectorSetType::Pointer                     VectorSetPointer;
00131 
00133   typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> IMatrixType;
00134 
00136   virtual bool GetHasNonZeroSpatialHessian( void ) const
00137   {
00138     return true;
00139   }
00140   virtual bool HasNonZeroJacobianOfSpatialHessian( void ) const
00141   {
00142     return true;
00143   }
00144 
00146   virtual unsigned int GetNumberOfParameters(void) const
00147   {
00148     return ( this->m_SourceLandmarks->GetNumberOfPoints() * SpaceDimension );
00149   }
00150 
00152   itkGetObjectMacro( SourceLandmarks, PointSetType );
00153 
00155   virtual void SetSourceLandmarks( PointSetType * );
00156 
00158   itkGetObjectMacro( TargetLandmarks, PointSetType );
00159 
00161   virtual void SetTargetLandmarks( PointSetType * );
00162 
00166   itkGetObjectMacro( Displacements, VectorSetType );
00167 
00169   void ComputeWMatrix( void );
00170 
00172   void ComputeLInverse( void );
00173 
00175   virtual OutputPointType TransformPoint( const InputPointType & thisPoint ) const;
00176 
00178   virtual const JacobianType & GetJacobian( const InputPointType & point ) const;
00179 
00181   virtual void GetJacobian(
00182     const InputPointType &,
00183     JacobianType &,
00184     NonZeroJacobianIndicesType & ) const;
00185 
00187   virtual void SetIdentity( void );
00188 
00194   virtual void SetParameters( const ParametersType & );
00195 
00201   virtual void SetFixedParameters( const ParametersType & );
00202 
00204   virtual void UpdateParameters( void );
00205 
00207   virtual const ParametersType & GetParameters( void ) const;
00208 
00210   virtual const ParametersType & GetFixedParameters( void ) const;
00211 
00222   virtual void SetStiffness( double stiffness )
00223   {
00224     this->m_Stiffness = stiffness > 0 ? stiffness : 0.0;
00225     this->m_LMatrixComputed = false;
00226     this->m_LInverseComputed = false;
00227     this->m_WMatrixComputed = false;
00228   }
00229   itkGetMacro( Stiffness, double );
00230 
00237   virtual void SetAlpha( TScalarType Alpha ) {};
00238   virtual TScalarType GetAlpha( void ) const { return -1.0; }
00239 
00246   itkSetMacro( PoissonRatio, TScalarType );
00247   virtual const TScalarType GetPoissonRatio( void ) const
00248   {
00249     return this->m_PoissonRatio;
00250   };
00251 
00252 protected:
00253   KernelTransform2();
00254   virtual ~KernelTransform2() {};
00255   void PrintSelf( std::ostream& os, Indent indent ) const;
00256 
00257 public:
00259   typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> GMatrixType;
00260 
00262   typedef vnl_matrix<TScalarType> LMatrixType;
00263 
00265   typedef vnl_matrix<TScalarType> KMatrixType;
00266 
00268   typedef vnl_matrix<TScalarType> PMatrixType;
00269 
00271   typedef vnl_matrix<TScalarType> YMatrixType;
00272 
00274   typedef vnl_matrix<TScalarType> WMatrixType;
00275 
00277   typedef vnl_matrix<TScalarType> DMatrixType;
00278 
00280   typedef vnl_matrix_fixed<TScalarType,NDimensions,NDimensions> AMatrixType;
00281 
00283   typedef vnl_vector_fixed<TScalarType,NDimensions> BMatrixType;
00284 
00286   typedef vnl_matrix_fixed<TScalarType, 1, NDimensions> RowMatrixType;
00287 
00289   typedef vnl_matrix_fixed<TScalarType, NDimensions, 1> ColumnMatrixType;
00290 
00292   PointSetPointer m_SourceLandmarks;
00293 
00295   PointSetPointer m_TargetLandmarks;
00296 
00297 protected:
00298 
00306   virtual void ComputeG( const InputVectorType & landmarkVector,
00307     GMatrixType & GMatrix ) const;
00308 
00316   virtual void ComputeReflexiveG( PointsIterator, GMatrixType & GMatrix ) const;
00317 
00321   virtual void ComputeDeformationContribution(
00322     const InputPointType & inputPoint,
00323     OutputPointType & result ) const;
00324 
00326   void ComputeK( void );
00327 
00329   void ComputeL( void );
00330 
00332   void ComputeP( void );
00333 
00335   void ComputeY( void );
00336 
00338   void ComputeD( void );
00339 
00344   void ReorganizeW( void );
00345 
00347   double m_Stiffness;
00348 
00352   VectorSetPointer m_Displacements;
00353 
00355   LMatrixType m_LMatrix;
00356 
00358   LMatrixType m_LMatrixInverse;
00359 
00361   KMatrixType m_KMatrix;
00362 
00364   PMatrixType m_PMatrix;
00365 
00367   YMatrixType m_YMatrix;
00368 
00370   WMatrixType m_WMatrix;
00371 
00377   DMatrixType m_DMatrix;
00378 
00380   AMatrixType m_AMatrix;
00381 
00383   BMatrixType m_BVector;
00384 
00390   //GMatrixType m_GMatrix;
00391 
00393   bool m_WMatrixComputed;
00395   bool m_LMatrixComputed;
00397   bool m_LInverseComputed;
00398 
00400   IMatrixType m_I;
00401 
00403   NonZeroJacobianIndicesType m_NonZeroJacobianIndices;
00404 
00406   mutable NonZeroJacobianIndicesType m_NonZeroJacobianIndicesTemp;
00407 
00408 private:
00409   KernelTransform2(const Self&); //purposely not implemented
00410   void operator=(const Self&); //purposely not implemented
00411 
00412   TScalarType m_PoissonRatio;
00413 
00414 };
00415 
00416 } // end namespace itk
00417 
00418 #ifndef ITK_MANUAL_INSTANTIATION
00419 #include "itkKernelTransform2.txx"
00420 #endif
00421 
00422 #endif // __itkKernelTransform2_h


Generated on 11-05-2011 for elastix by doxygen 1.7.4 elastix logo