Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkImageMomentsCalculator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageMomentsCalculator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-24 20:02:56 $
00007   Version:   $Revision: 1.42 $
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 __itkImageMomentsCalculator_h
00018 #define __itkImageMomentsCalculator_h
00019 
00020 #include "itkAffineTransform.h"
00021 #include "itkMacro.h"
00022 #include "itkImage.h"
00023 #include "itkSpatialObject.h"
00024 
00025 #include "vnl/vnl_vector_fixed.h"
00026 #include "vnl/vnl_matrix_fixed.h"
00027 #include "vnl/vnl_diag_matrix.h"
00028 
00029 namespace itk
00030 {
00031 
00059 template < class TImage >
00060 class ITK_EXPORT ImageMomentsCalculator : public Object
00061 {
00062 public:
00064   typedef ImageMomentsCalculator<TImage>   Self;
00065   typedef Object                           Superclass;
00066   typedef SmartPointer<Self>               Pointer;
00067   typedef SmartPointer<const Self>         ConstPointer;
00068 
00070   itkNewMacro(Self);
00071 
00073   itkTypeMacro(ImageMomentsCalculator, Object);
00074 
00076   itkStaticConstMacro(ImageDimension, unsigned int,
00077                       TImage::ImageDimension);
00078 
00080   typedef double                       ScalarType;
00081 
00083   typedef Vector<ScalarType,itkGetStaticConstMacro(ImageDimension)> VectorType;
00084 
00086   typedef SpatialObject< itkGetStaticConstMacro(ImageDimension) > SpatialObjectType;
00087 
00089   typedef typename SpatialObjectType::Pointer      SpatialObjectPointer;
00090   typedef typename SpatialObjectType::ConstPointer SpatialObjectConstPointer;
00091 
00093   typedef Matrix<ScalarType,
00094                  itkGetStaticConstMacro(ImageDimension),
00095                  itkGetStaticConstMacro(ImageDimension)>   MatrixType;
00096 
00098   typedef TImage ImageType;
00099 
00101   typedef typename ImageType::Pointer      ImagePointer;
00102   typedef typename ImageType::ConstPointer ImageConstPointer;
00103 
00105   typedef AffineTransform<double,itkGetStaticConstMacro(ImageDimension)> AffineTransformType;
00106   typedef typename AffineTransformType::Pointer      AffineTransformPointer;
00107 
00109   virtual void SetImage( const ImageType * image )
00110     {
00111     if ( m_Image != image )
00112       {
00113       m_Image = image;
00114       this->Modified();
00115       m_Valid = false;
00116       }
00117     }
00119 
00120 
00122   virtual void SetSpatialObjectMask( const SpatialObject< itkGetStaticConstMacro( ImageDimension ) > * so )
00123     {
00124     if ( m_SpatialObjectMask != so )
00125       {
00126       m_SpatialObjectMask = so;
00127       this->Modified();
00128       m_Valid = false;
00129       }
00130     }
00132 
00138   void Compute( void );
00139 
00144   ScalarType GetTotalMass() const;
00145 
00151   VectorType GetFirstMoments() const;
00152 
00158   MatrixType GetSecondMoments() const;
00159 
00164   VectorType GetCenterOfGravity() const;
00165 
00170   MatrixType GetCentralMoments() const;
00171 
00178   VectorType GetPrincipalMoments() const;
00179 
00192   MatrixType GetPrincipalAxes() const;
00194 
00198   AffineTransformPointer GetPrincipalAxesToPhysicalAxesTransform(void) const;
00199 
00204   AffineTransformPointer GetPhysicalAxesToPrincipalAxesTransform(void) const;
00205 
00206 protected:
00207   ImageMomentsCalculator();
00208   virtual ~ImageMomentsCalculator();
00209   void PrintSelf(std::ostream& os, Indent indent) const;
00210 
00211 private:
00212   ImageMomentsCalculator(const Self&); //purposely not implemented
00213   void operator=(const Self&); //purposely not implemented
00214 
00215   bool       m_Valid;                // Have moments been computed yet?
00216   ScalarType m_M0;                   // Zeroth moment
00217   VectorType m_M1;                   // First moments about origin
00218   MatrixType m_M2;                   // Second moments about origin
00219   VectorType m_Cg;                   // Center of gravity (physical units)
00220   MatrixType m_Cm;                   // Second central moments (physical)
00221   VectorType m_Pm;                   // Principal moments (physical)
00222   MatrixType m_Pa;                   // Principal axes (physical)
00223 
00224   ImageConstPointer         m_Image;
00225   SpatialObjectConstPointer m_SpatialObjectMask;
00226 
00227 };  // class ImageMomentsCalculator
00228 
00229 } // end namespace itk
00230 
00231 
00232 #ifndef ITK_MANUAL_INSTANTIATION
00233 #include "itkImageMomentsCalculator.txx"
00234 #endif
00235 
00236 #endif /* __itkImageMomentsCalculator_h */
00237 

Generated at Sat Feb 28 12:41:34 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000