00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageMomentsCalculator_h
00018 #define __itkImageMomentsCalculator_h
00019
00020 #include "itkAffineTransform.h"
00021 #include "itkMacro.h"
00022 #include "itkImage.h"
00023
00024 #include "vnl/vnl_vector_fixed.h"
00025 #include "vnl/vnl_matrix_fixed.h"
00026 #include "vnl/vnl_diag_matrix.h"
00027
00028 namespace itk
00029 {
00030
00058 template < class TImage >
00059 class ITK_EXPORT ImageMomentsCalculator : public Object
00060 {
00061 public:
00063 typedef ImageMomentsCalculator<TImage> Self;
00064 typedef Object Superclass;
00065 typedef SmartPointer<Self> Pointer;
00066 typedef SmartPointer<const Self> ConstPointer;
00067
00069 itkNewMacro(Self);
00070
00072 itkTypeMacro(ImageMomentsCalculator, Object);
00073
00075 itkStaticConstMacro(ImageDimension, unsigned int,
00076 TImage::ImageDimension);
00077
00079 typedef double ScalarType;
00080
00082 typedef Vector<ScalarType,itkGetStaticConstMacro(ImageDimension)> VectorType;
00083
00085 typedef Matrix<ScalarType,
00086 itkGetStaticConstMacro(ImageDimension),
00087 itkGetStaticConstMacro(ImageDimension)> MatrixType;
00088
00090 typedef TImage ImageType;
00091
00093 typedef typename ImageType::Pointer ImagePointer;
00094 typedef typename ImageType::ConstPointer ImageConstPointer;
00095
00097 typedef AffineTransform<double,itkGetStaticConstMacro(ImageDimension)> AffineTransformType;
00098 typedef typename AffineTransformType::Pointer AffineTransformPointer;
00099
00101 virtual void SetImage( const ImageType * image )
00102 {
00103 if ( m_Image != image )
00104 {
00105 m_Image = image;
00106 this->Modified();
00107 m_Valid = false;
00108 }
00109 }
00111
00117 void Compute( void );
00118
00123 ScalarType GetTotalMass() const;
00124
00130 VectorType GetFirstMoments() const;
00131
00137 MatrixType GetSecondMoments() const;
00138
00143 VectorType GetCenterOfGravity() const;
00144
00149 MatrixType GetCentralMoments() const;
00150
00157 VectorType GetPrincipalMoments() const;
00158
00171 MatrixType GetPrincipalAxes() const;
00173
00177 AffineTransformPointer GetPrincipalAxesToPhysicalAxesTransform(void) const;
00178
00183 AffineTransformPointer GetPhysicalAxesToPrincipalAxesTransform(void) const;
00184
00185 protected:
00186 ImageMomentsCalculator();
00187 virtual ~ImageMomentsCalculator();
00188 void PrintSelf(std::ostream& os, Indent indent) const;
00189
00190 private:
00191 ImageMomentsCalculator(const Self&);
00192 void operator=(const Self&);
00193
00194 bool m_Valid;
00195 ScalarType m_M0;
00196 VectorType m_M1;
00197 MatrixType m_M2;
00198 VectorType m_Cg;
00199 MatrixType m_Cm;
00200 VectorType m_Pm;
00201 MatrixType m_Pa;
00202
00203 ImageConstPointer m_Image;
00204
00205 };
00206
00207 }
00208
00209
00210 #ifndef ITK_MANUAL_INSTANTIATION
00211 #include "itkImageMomentsCalculator.txx"
00212 #endif
00213
00214 #endif
00215