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 }
00110
00116 void Compute( void );
00117
00122 ScalarType GetTotalMass() const;
00123
00129 VectorType GetFirstMoments() const;
00130
00136 MatrixType GetSecondMoments() const;
00137
00142 VectorType GetCenterOfGravity() const;
00143
00148 MatrixType GetCentralMoments() const;
00149
00156 VectorType GetPrincipalMoments() const;
00157
00170 MatrixType GetPrincipalAxes() const;
00171
00175 AffineTransformPointer GetPrincipalAxesToPhysicalAxesTransform(void) const;
00176
00181 AffineTransformPointer GetPhysicalAxesToPrincipalAxesTransform(void) const;
00182
00183 protected:
00184 ImageMomentsCalculator();
00185 virtual ~ImageMomentsCalculator();
00186 void PrintSelf(std::ostream& os, Indent indent) const;
00187
00188 private:
00189 ImageMomentsCalculator(const Self&);
00190 void operator=(const Self&);
00191
00192 bool m_Valid;
00193 ScalarType m_M0;
00194 VectorType m_M1;
00195 MatrixType m_M2;
00196 VectorType m_Cg;
00197 MatrixType m_Cm;
00198 VectorType m_Pm;
00199 MatrixType m_Pa;
00200
00201 ImageConstPointer m_Image;
00202
00203 };
00204
00205 }
00206
00207
00208 #ifndef ITK_MANUAL_INSTANTIATION
00209 #include "itkImageMomentsCalculator.txx"
00210 #endif
00211
00212 #endif