Difference between revisions of "NAMIC Wiki:DTI:ITK"

From NAMIC Wiki
Jump to: navigation, search
m (Update from Wiki)
m (Update from Wiki)
Line 1: Line 1:
Header for proposed itkSymmetricTensor.
+
Header for proposed itkSymmetricTensorTraits.
  
 
  <nowiki>
 
  <nowiki>
Line 5: Line 5:
 
   
 
   
 
   Program:  Insight Segmentation & Registration Toolkit
 
   Program:  Insight Segmentation & Registration Toolkit
   Module:    $RCSfile: itkSymmetricTensor.txx,v $
+
   Module:    $RCSfile: itkSymmetricTensorTraits.h,v $
 
   Language:  C++
 
   Language:  C++
   Date:      $Date: 2004/04/15 22:37:33 $
+
   Date:      $Date$
   Version:  $Revision: 1.10 $
+
   Version:  $Revision$
 
   
 
   
 
   Copyright (c) Insight Software Consortium. All rights reserved.
 
   Copyright (c) Insight Software Consortium. All rights reserved.
Line 19: Line 19:
 
  =========================================================================*/
 
  =========================================================================*/
 
   
 
   
  #ifndef __itkSymmetricTensor_h
+
  #ifndef __itkSymmetricTensorTraits_h
  #define __itkSymmetricTensor_h
+
  #define __itkSymmetricTensorTraits_h
 
   
 
   
 
  #include "itkFixedArray.h"
 
  #include "itkFixedArray.h"
#include "itkSymmetricTensorTraits.h"
 
#include "vnl/vnl_matrix.h"
 
 
   
 
   
 
  namespace itk
 
  namespace itk
 
  {
 
  {
  /** \class itkSymmetricTensor
+
  /** \class itkSymmetricTensorTraits
 
   *
 
   *
 
   */
 
   */
  template
+
  template<typename TRealType, unsigned int VTensorDimension>
  < typename TRealType = float, unsigned int VTensorDimension = 3,
+
  class ITK_EXPORT SymmetricTensorTraits
  typename TTensorTraits = SymmetricTensorTraits<TRealType,VTensorDimension>
 
>
 
  class ITK_EXPORT SymmetricTensor :
 
    public FixedArray< TRealType, VTensorDimension*(VTensorDimension+1)/2 >
 
 
  {
 
  {
  public:
+
public:
   /// The compact linear vector dimension of the tensor.
+
   static const unsigned int NTensorDimension = VTensorDimension;
 
   static const unsigned int NVectorDimension =
 
   static const unsigned int NVectorDimension =
    VTensorDimension*(VTensorDimension+1)/2;
+
  VTensorDimension * (VTensorDimension+1) / 2;
 
   
 
   
 
   /** Standard class typedefs. */
 
   /** Standard class typedefs. */
   typedef SymmetricTensor Self;
+
   typedef SymmetricTensorTraits Self;
  typedef SmartPointer<Self> Pointer;
+
   typedef FixedArray<TRealType,NVectorDimension> SymmetricTensorBaseType;
  typedef SmartPointer<const Self>  ConstPointer;
 
   typedef FixedArray< TRealType, NVectorDimension > Superclass;
 
 
   
 
   
   /** Run-time type information (and related methods) */
+
   /// Perform eigenvalue computation.
   itkTypeMacro(SymmetricTensor, FixedArray);
+
   static void ComputeEigenvalues( const SymmetricTensorBaseType& tensor,
 +
  double (&lambda)[VTensorDimension] );
 +
};
 
   
 
   
  /** Define the data type and the vector of data type used in calculations.
+
/// Specialization for 3D tensors.
   */
+
template<typename TRealType>
   typedef TRealType RealType;
+
class ITK_EXPORT SymmetricTensorTraits<TRealType,3>
 +
{
 +
public:
 +
   static const unsigned int NTensorDimension = 3;
 +
   static const unsigned int NVectorDimension = 6;
 
   
 
   
  typedef vnl_matrix_fixed<TRealType,VTensorDimension,VTensorDimension> VnlMatrixType;
+
   /** Standard class typedefs. */
   /* Return vnl_matrix object. We do this here, since it's always the same,
+
   typedef SymmetricTensorTraits Self;
    * regardless of tensor size.
+
   typedef FixedArray<TRealType,NVectorDimension> SymmetricTensorBaseType;
    */
 
  VnlMatrixType GetVnlMatrix() const;
 
 
  /** Compute eigenvalues. This is done in the traits class, since the best
 
    * implementation depends on the actual tensor size.
 
    */
 
   void ComputeEigenvalues( double (&lambda)[VTensorDimension] ) const
 
    {
 
    TTensorTraits::ComputeEigenvalues( *this, lambda );
 
    }
 
 
  SymmetricTensor() : Superclass() {}
 
  SymmetricTensor(const Self& other) : Superclass( other ) {}
 
  void operator=(const Self& other) { this->Superclass::operator=( other ); }
 
 
   /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  SymmetricTensor(const Vector<TRealType,NVectorDimension>& other) :
 
    Superclass( other ) {}
 
 
  /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  typedef TRealType ComponentType;
 
 
  /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  static int GetNumberOfComponents()
 
    { return VTensorDimension*(VTensorDimension+1)/2;}
 
 
  /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  void SetNthComponent(int c, const ComponentType& v)
 
  {  this->operator[](c) = v; }
 
 
   
 
   
protected:
+
  /// Perform eigenvalue computation.
   void PrintSelf(std::ostream& os, Indent indent) const;
+
   static void ComputeEigenvalues( const SymmetricTensorBaseType& tensor,
 +
  double (&lambda)[3] );
 
  };
 
  };
 
   
 
   
Line 108: Line 66:
 
   
 
   
 
  #ifndef ITK_MANUAL_INSTANTIATION
 
  #ifndef ITK_MANUAL_INSTANTIATION
  #include "itkSymmetricTensor.txx"
+
  #include "itkSymmetricTensorTraits.txx"
 
  #endif
 
  #endif
 
   
 
   

Revision as of 14:06, 18 December 2006

Home < NAMIC Wiki:DTI:ITK

Header for proposed itkSymmetricTensorTraits.

 /*=========================================================================
 
   Program:   Insight Segmentation & Registration Toolkit
   Module:    $RCSfile: itkSymmetricTensorTraits.h,v $
   Language:  C++
   Date:      $Date$
   Version:   $Revision$
 
   Copyright (c) Insight Software Consortium. All rights reserved.
   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
 
      This software is distributed WITHOUT ANY WARRANTY; without even
      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
      PURPOSE.  See the above copyright notices for more information.
 
 =========================================================================*/
 
 #ifndef __itkSymmetricTensorTraits_h
 #define __itkSymmetricTensorTraits_h
 
 #include "itkFixedArray.h"
 
 namespace itk
 {
 /** \class itkSymmetricTensorTraits
  *
  */
 template<typename TRealType, unsigned int VTensorDimension>
 class ITK_EXPORT SymmetricTensorTraits
 {
 public:
   static const unsigned int NTensorDimension = VTensorDimension;
   static const unsigned int NVectorDimension =
   VTensorDimension * (VTensorDimension+1) / 2;
 
   /** Standard class typedefs. */
   typedef SymmetricTensorTraits Self;
   typedef FixedArray<TRealType,NVectorDimension> SymmetricTensorBaseType;
 
   /// Perform eigenvalue computation.
   static void ComputeEigenvalues( const SymmetricTensorBaseType& tensor,
 				  double (&lambda)[VTensorDimension] );
 };
 
 /// Specialization for 3D tensors.
 template<typename TRealType>
 class ITK_EXPORT SymmetricTensorTraits<TRealType,3>
 {
 public:
   static const unsigned int NTensorDimension = 3;
   static const unsigned int NVectorDimension = 6;
 
   /** Standard class typedefs. */
   typedef SymmetricTensorTraits Self;
   typedef FixedArray<TRealType,NVectorDimension> SymmetricTensorBaseType;
 
   /// Perform eigenvalue computation.
   static void ComputeEigenvalues( const SymmetricTensorBaseType& tensor,
 				  double (&lambda)[3] );
 };
 
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
 #include "itkSymmetricTensorTraits.txx"
 #endif
 
 #endif