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

itkImagePCAShapeModelEstimator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImagePCAShapeModelEstimator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/08/06 22:44:25 $
00007   Version:   $Revision: 1.6 $
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 _itkImagePCAShapeModelEstimator_h
00018 #define _itkImagePCAShapeModelEstimator_h
00019 
00020 #include <time.h>
00021 #include <math.h>
00022 #include <float.h>
00023 
00024 #include "vnl/vnl_vector.h"
00025 #include "vnl/vnl_matrix.h"
00026 #include "vnl/vnl_math.h"
00027 #include "vnl/algo/vnl_matrix_inverse.h"
00028 
00029 #include "itkImageRegionIterator.h"
00030 #include "itkImageRegionConstIterator.h"
00031 #include "itkExceptionObject.h"
00032 
00033 #include "itkImageShapeModelEstimatorBase.h"
00034 #include "itkConceptChecking.h"
00035 #include "itkImage.h"
00036 #include <vnl/algo/vnl_generalized_eigensystem.h>
00037 #include <vnl/algo/vnl_symmetric_eigensystem.h>
00038 
00039 namespace itk
00040 {
00041 
00070 template <class TInputImage, 
00071           class TOutputImage= Image<double, ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00072 class ITK_EXPORT ImagePCAShapeModelEstimator: 
00073     public ImageShapeModelEstimatorBase<TInputImage, TOutputImage>
00074 {
00075 public:
00077   typedef ImagePCAShapeModelEstimator   Self;
00078   typedef ImageShapeModelEstimatorBase<TInputImage, TOutputImage> Superclass;
00079   typedef SmartPointer<Self>  Pointer;
00080   typedef SmartPointer<const Self>  ConstPointer;
00081 
00083   itkNewMacro(Self);
00084 
00086   itkTypeMacro(ImagePCAShapeModelEstimator, ImageShapeModelEstimatorBase);
00087 
00089   typedef TInputImage                           InputImageType;
00090   typedef typename TInputImage::Pointer         InputImagePointer;
00091   typedef typename TInputImage::ConstPointer    InputImageConstPointer;
00092 
00094   typedef typename TInputImage::PixelType   InputImagePixelType;
00095 
00097   typedef 
00098     ImageRegionIterator<TInputImage> InputImageIterator;
00099 
00100   typedef 
00101     ImageRegionConstIterator<TInputImage> InputImageConstIterator;    
00102 
00104   itkStaticConstMacro(InputImageDimension, unsigned int,
00105                       TInputImage::ImageDimension); 
00106 
00108   typedef TOutputImage                    OutputImageType;
00109   typedef typename TOutputImage::Pointer  OutputImagePointer;
00110 
00112   typedef 
00113     ImageRegionIterator<TOutputImage> OutputImageIterator;
00114 
00116   typedef vnl_matrix<double> MatrixOfDoubleType; 
00117 
00119   typedef vnl_matrix<int>    MatrixOfIntegerType;
00120 
00122   typedef vnl_vector<double> VectorOfDoubleType;
00123 
00127   virtual void SetNumberOfPrincipalComponentsRequired( unsigned int n );
00128   itkGetMacro( NumberOfPrincipalComponentsRequired, unsigned int );
00129 
00131   virtual void SetNumberOfTrainingImages( unsigned int n );
00132   itkGetMacro(NumberOfTrainingImages, unsigned int);
00133 
00135   itkGetMacro(EigenValues, VectorOfDoubleType);  
00136 
00137 protected: 
00138   ImagePCAShapeModelEstimator();
00139   ~ImagePCAShapeModelEstimator();
00140   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00141 
00145   virtual void EnlargeOutputRequestedRegion( DataObject * );
00146 
00151   virtual void GenerateInputRequestedRegion();
00152 
00154   void GenerateData() ;
00155 
00156 private:
00157 
00158   ImagePCAShapeModelEstimator(const Self&); //purposely not implemented
00159   void operator=(const Self&); //purposely not implemented
00160 
00162   typedef 
00163     std::vector<InputImageConstPointer> InputImagePointerArray;
00164   typedef
00165     std::vector< InputImageConstIterator > InputImageIteratorArray;
00166 
00167   typedef typename TInputImage::SizeType ImageSizeType;
00168 
00170   typedef typename TInputImage::PixelType InputPixelType;
00171 
00180   virtual void EstimateShapeModels();
00181 
00182   void EstimatePCAShapeModelParameters();
00183 
00184   void CalculateInnerProduct();
00185 
00187   InputImageIteratorArray m_InputImageIteratorArray;
00188 
00189   VectorOfDoubleType    m_Means; 
00190 
00191   MatrixOfDoubleType    m_InnerProduct;
00192 
00193   MatrixOfDoubleType    m_EigenVectors;
00194 
00195   VectorOfDoubleType    m_EigenValues;
00196 
00197   VectorOfDoubleType    m_EigenVectorNormalizedEnergy;
00198 
00199   ImageSizeType         m_InputImageSize;
00200 
00201   unsigned int          m_NumberOfPixels;
00202 
00203   // The number of input images for PCA
00204   unsigned int          m_NumberOfTrainingImages;
00205 
00206   // The number of output Pricipal Components
00207   unsigned int          m_NumberOfPrincipalComponentsRequired;
00208   
00209 }; // class ImagePCAShapeModelEstimator
00210 
00211 
00212 } // namespace itk
00213 
00214 #ifndef ITK_MANUAL_INSTANTIATION
00215 #include "itkImagePCAShapeModelEstimator.txx"
00216 #endif
00217 
00218 
00219 
00220 #endif

Generated at Wed May 24 23:21:11 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000