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: 2009-04-23 03:53:35 $
00007   Version:   $Revision: 1.8 $
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 ImageRegionIterator<TInputImage>      InputImageIterator;
00098   typedef ImageRegionConstIterator<TInputImage> InputImageConstIterator;
00099 
00101   itkStaticConstMacro(InputImageDimension, unsigned int,
00102                       TInputImage::ImageDimension); 
00103 
00105   typedef TOutputImage                    OutputImageType;
00106   typedef typename TOutputImage::Pointer  OutputImagePointer;
00107 
00109   typedef ImageRegionIterator<TOutputImage> OutputImageIterator;
00110 
00112   typedef vnl_matrix<double> MatrixOfDoubleType; 
00113 
00115   typedef vnl_matrix<int>    MatrixOfIntegerType;
00116 
00118   typedef vnl_vector<double> VectorOfDoubleType;
00119 
00124   virtual void SetNumberOfPrincipalComponentsRequired( unsigned int n );
00125   itkGetConstMacro( NumberOfPrincipalComponentsRequired, unsigned int );
00127 
00129   virtual void SetNumberOfTrainingImages( unsigned int n );
00130   itkGetConstMacro(NumberOfTrainingImages, unsigned int);
00132 
00134   itkGetConstMacro(EigenValues, VectorOfDoubleType);  
00135 
00136 protected: 
00137   ImagePCAShapeModelEstimator();
00138   ~ImagePCAShapeModelEstimator();
00139   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00140 
00144   virtual void EnlargeOutputRequestedRegion( DataObject * );
00145 
00150   virtual void GenerateInputRequestedRegion();
00151 
00153   void GenerateData();
00154 
00155 private:
00156 
00157   ImagePCAShapeModelEstimator(const Self&); //purposely not implemented
00158   void operator=(const Self&); //purposely not implemented
00159 
00161   typedef std::vector<InputImageConstPointer>    InputImagePointerArray;
00162   typedef std::vector< InputImageConstIterator > InputImageIteratorArray;
00163 
00164   typedef typename TInputImage::SizeType ImageSizeType;
00165 
00167   typedef typename TInputImage::PixelType InputPixelType;
00168 
00177   virtual void EstimateShapeModels();
00178 
00179   void EstimatePCAShapeModelParameters();
00180 
00181   void CalculateInnerProduct();
00182 
00184   InputImageIteratorArray m_InputImageIteratorArray;
00185 
00186   VectorOfDoubleType    m_Means; 
00187 
00188   MatrixOfDoubleType    m_InnerProduct;
00189 
00190   MatrixOfDoubleType    m_EigenVectors;
00191 
00192   VectorOfDoubleType    m_EigenValues;
00193 
00194   VectorOfDoubleType    m_EigenVectorNormalizedEnergy;
00195 
00196   ImageSizeType         m_InputImageSize;
00197 
00198   unsigned int          m_NumberOfPixels;
00199 
00200   // The number of input images for PCA
00201   unsigned int          m_NumberOfTrainingImages;
00202 
00203   // The number of output Pricipal Components
00204   unsigned int          m_NumberOfPrincipalComponentsRequired;
00205   
00206 }; // class ImagePCAShapeModelEstimator
00207 
00208 
00209 } // namespace itk
00210 
00211 #ifndef ITK_MANUAL_INSTANTIATION
00212 #include "itkImagePCAShapeModelEstimator.txx"
00213 #endif
00214 
00215 #endif
00216 

Generated at Thu May 28 10:19:07 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000