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
00058 template <class TInputImage,
00059 class TBasisImage = Image<double, ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00060 class ITK_EXPORT ImagePCADecompositionCalculator : public Object
00061 {
00062 public:
00064 typedef ImagePCADecompositionCalculator Self;
00065 typedef Object Superclass;
00066 typedef SmartPointer<Self> Pointer;
00067 typedef SmartPointer<const Self> ConstPointer;
00068
00070 itkNewMacro(Self);
00071
00073 itkTypeMacro(ImagePCADecompositionCalculator, Object);
00074
00076 typedef TInputImage InputImageType;
00077 typedef TBasisImage BasisImageType;
00078
00080 typedef typename TInputImage::Pointer InputImagePointer;
00081 typedef typename TBasisImage::Pointer BasisImagePointer;
00082
00084 typedef typename TInputImage::ConstPointer InputImageConstPointer;
00085 typedef typename TBasisImage::ConstPointer BasisImageConstPointer;
00086
00088 typedef typename TBasisImage::PixelType BasisPixelType;
00090 itkStaticConstMacro(InputImageDimension, unsigned int,
00091 TInputImage::ImageDimension);
00092
00094 itkStaticConstMacro(BasisImageDimension, unsigned int,
00095 TBasisImage::ImageDimension);
00096
00097
00099 typedef std::vector< BasisImagePointer > BasisImagePointerVector;
00100
00102 typedef vnl_matrix<BasisPixelType> BasisMatrixType;
00103 typedef vnl_vector<BasisPixelType> BasisVectorType;
00104
00106 itkSetConstObjectMacro(Image, InputImageType);
00107 itkGetConstObjectMacro(Image, InputImageType);
00108
00110 itkSetConstObjectMacro(MeanImage, BasisImageType);
00111 itkGetConstObjectMacro(MeanImage, BasisImageType);
00112
00114 void SetBasisImages(const BasisImagePointerVector &);
00115 BasisImagePointerVector GetBasisImages() { return m_BasisImages; }
00116
00118 typedef typename ImagePCAShapeModelEstimator<TInputImage,
00119 TBasisImage>::Pointer ModelPointerType;
00121 void SetBasisFromModel(ModelPointerType model);
00122
00124 void Compute(void);
00125
00127 itkGetMacro(Projection,BasisVectorType);
00128
00129
00130 protected:
00131 ImagePCADecompositionCalculator();
00132 virtual ~ImagePCADecompositionCalculator() {};
00133 void PrintSelf(std::ostream& os, Indent indent) const;
00134 void CalculateBasisMatrix(void);
00135 void CalculateRecenteredImageAsVector(void);
00136
00137 private:
00138 typedef typename BasisImageType::SizeType BasisSizeType;
00139
00140 ImagePCADecompositionCalculator(const Self&);
00141 void operator=(const Self&);
00142
00143 BasisVectorType m_Projection;
00144 BasisVectorType m_ImageAsVector;
00145 BasisImagePointerVector m_BasisImages;
00146 BasisImageConstPointer m_MeanImage;
00147 BasisSizeType m_Size;
00148 InputImageConstPointer m_Image;
00149 BasisMatrixType m_BasisMatrix;
00150 bool m_BasisMatrixCalculated;
00151 unsigned long m_NumPixels;
00152 };
00153
00154 }
00155
00156
00157 #ifndef ITK_MANUAL_INSTANTIATION
00158 #include "itkImagePCADecompositionCalculator.txx"
00159 #endif
00160
00161 #endif