00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkImagePCADecompositionCalculator_h
00019 #define __itkImagePCADecompositionCalculator_h
00020
00021 #include "itkObject.h"
00022 #include "itkImagePCAShapeModelEstimator.h"
00023 #include "vnl/vnl_vector.h"
00024 #include "vnl/vnl_matrix.h"
00025
00026 namespace itk
00027 {
00028
00057 template <class TInputImage,
00058 class TBasisImage = Image<double, ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00059 class ITK_EXPORT ImagePCADecompositionCalculator : public Object
00060 {
00061 public:
00063 typedef ImagePCADecompositionCalculator Self;
00064 typedef Object Superclass;
00065 typedef SmartPointer<Self> Pointer;
00066 typedef SmartPointer<const Self> ConstPointer;
00067
00069 itkNewMacro(Self);
00070
00072 itkTypeMacro(ImagePCADecompositionCalculator, Object);
00073
00075 typedef TInputImage InputImageType;
00076 typedef TBasisImage BasisImageType;
00077
00079 typedef typename TInputImage::Pointer InputImagePointer;
00080 typedef typename TBasisImage::Pointer BasisImagePointer;
00081
00083 typedef typename TInputImage::ConstPointer InputImageConstPointer;
00084
00086 typedef typename TBasisImage::PixelType BasisPixelType;
00088 itkStaticConstMacro(InputImageDimension, unsigned int,
00089 TInputImage::ImageDimension);
00090
00092 itkStaticConstMacro(BasisImageDimension, unsigned int,
00093 TBasisImage::ImageDimension);
00094
00095
00097 typedef std::vector< BasisImagePointer > BasisImagePointerVector;
00098
00100 typedef vnl_matrix<BasisPixelType> BasisMatrixType;
00101 typedef vnl_vector<BasisPixelType> BasisVectorType;
00102
00104 itkSetConstObjectMacro(Image,InputImageType);
00105
00107 void SetBasisImages(const BasisImagePointerVector _arg);
00108
00110 BasisImagePointerVector& GetBasisImages(void) {return m_BasisImages;}
00111
00113 typedef typename ImagePCAShapeModelEstimator<TInputImage,
00114 TBasisImage>::Pointer ModelPointerType;
00116 void SetBasisFromModel(ModelPointerType model);
00117
00119 void Compute(void);
00120
00122 itkGetMacro(Projection,BasisVectorType);
00123
00124
00125 protected:
00126 ImagePCADecompositionCalculator();
00127 virtual ~ImagePCADecompositionCalculator() {};
00128 void PrintSelf(std::ostream& os, Indent indent) const;
00129 void CalculateBasisMatrix(void);
00130 void CalculateImageAsVector(void);
00131
00132 private:
00133 typedef typename BasisImageType::SizeType BasisSizeType;
00134
00135 ImagePCADecompositionCalculator(const Self&);
00136 void operator=(const Self&);
00137
00138 BasisVectorType m_Projection;
00139 BasisVectorType m_ImageAsVector;
00140 BasisImagePointerVector m_BasisImages;
00141 BasisSizeType m_Size;
00142 InputImageConstPointer m_Image;
00143 BasisMatrixType m_BasisMatrix;
00144 bool m_BasisMatrixCalculated;
00145 unsigned long m_NumPixels;
00146 };
00147
00148 }
00149
00150
00151 #ifndef ITK_MANUAL_INSTANTIATION
00152 #include "itkImagePCADecompositionCalculator.txx"
00153 #endif
00154
00155 #endif