Difference between revisions of "NAMIC Wiki:DTI:ITK"
From NAMIC Wiki
m (Update from Wiki) |
m (Update from Wiki) |
||
| Line 1: | Line 1: | ||
| − | + | Header for proposed itkSymmetricTensor. | |
| − | + | <nowiki> | |
| − | + | /*========================================================================= | |
| − | * [ | + | |
| − | + | Program: Insight Segmentation & Registration Toolkit | |
| − | * | + | Module: $RCSfile: itkSymmetricTensor.txx,v $ |
| − | + | Language: C++ | |
| − | + | Date: $Date: 2004/04/15 22:37:33 $ | |
| − | + | Version: $Revision: 1.10 $ | |
| − | * | + | |
| − | * [ | + | 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 __itkSymmetricTensor_h | ||
| + | #define __itkSymmetricTensor_h | ||
| + | |||
| + | #include "itkFixedArray.h" | ||
| + | #include "itkSymmetricTensorTraits.h" | ||
| + | #include "vnl/vnl_matrix.h" | ||
| + | |||
| + | namespace itk | ||
| + | { | ||
| + | /** \class itkSymmetricTensor | ||
| + | * | ||
| + | */ | ||
| + | template | ||
| + | < typename TRealType = float, unsigned int VTensorDimension = 3, | ||
| + | typename TTensorTraits = SymmetricTensorTraits<TRealType,VTensorDimension> | ||
| + | > | ||
| + | class ITK_EXPORT SymmetricTensor : | ||
| + | public FixedArray< TRealType, VTensorDimension*(VTensorDimension+1)/2 > | ||
| + | { | ||
| + | public: | ||
| + | /// The compact linear vector dimension of the tensor. | ||
| + | static const unsigned int NVectorDimension = | ||
| + | VTensorDimension*(VTensorDimension+1)/2; | ||
| + | |||
| + | /** Standard class typedefs. */ | ||
| + | typedef SymmetricTensor Self; | ||
| + | typedef SmartPointer<Self> Pointer; | ||
| + | typedef SmartPointer<const Self> ConstPointer; | ||
| + | typedef FixedArray< TRealType, NVectorDimension > Superclass; | ||
| + | |||
| + | /** Run-time type information (and related methods) */ | ||
| + | itkTypeMacro(SymmetricTensor, FixedArray); | ||
| + | |||
| + | /** Define the data type and the vector of data type used in calculations. | ||
| + | */ | ||
| + | typedef TRealType RealType; | ||
| + | |||
| + | typedef vnl_matrix_fixed<TRealType,VTensorDimension,VTensorDimension> VnlMatrixType; | ||
| + | /* Return vnl_matrix object. We do this here, since it's always the same, | ||
| + | * regardless of tensor size. | ||
| + | */ | ||
| + | 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: | ||
| + | void PrintSelf(std::ostream& os, Indent indent) const; | ||
| + | }; | ||
| + | |||
| + | } // end namespace itk | ||
| + | |||
| + | #ifndef ITK_MANUAL_INSTANTIATION | ||
| + | #include "itkSymmetricTensor.txx" | ||
| + | #endif | ||
| + | |||
| + | #endif | ||
| + | |||
| + | </nowiki> | ||
Revision as of 13:31, 18 December 2006
Home < NAMIC Wiki:DTI:ITKHeader for proposed itkSymmetricTensor.
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkSymmetricTensor.txx,v $
Language: C++
Date: $Date: 2004/04/15 22:37:33 $
Version: $Revision: 1.10 $
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 __itkSymmetricTensor_h
#define __itkSymmetricTensor_h
#include "itkFixedArray.h"
#include "itkSymmetricTensorTraits.h"
#include "vnl/vnl_matrix.h"
namespace itk
{
/** \class itkSymmetricTensor
*
*/
template
< typename TRealType = float, unsigned int VTensorDimension = 3,
typename TTensorTraits = SymmetricTensorTraits<TRealType,VTensorDimension>
>
class ITK_EXPORT SymmetricTensor :
public FixedArray< TRealType, VTensorDimension*(VTensorDimension+1)/2 >
{
public:
/// The compact linear vector dimension of the tensor.
static const unsigned int NVectorDimension =
VTensorDimension*(VTensorDimension+1)/2;
/** Standard class typedefs. */
typedef SymmetricTensor Self;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
typedef FixedArray< TRealType, NVectorDimension > Superclass;
/** Run-time type information (and related methods) */
itkTypeMacro(SymmetricTensor, FixedArray);
/** Define the data type and the vector of data type used in calculations.
*/
typedef TRealType RealType;
typedef vnl_matrix_fixed<TRealType,VTensorDimension,VTensorDimension> VnlMatrixType;
/* Return vnl_matrix object. We do this here, since it's always the same,
* regardless of tensor size.
*/
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:
void PrintSelf(std::ostream& os, Indent indent) const;
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkSymmetricTensor.txx"
#endif
#endif