ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkImagePCADecompositionCalculator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
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 {
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;
00089 
00091   itkStaticConstMacro(InputImageDimension, unsigned int,
00092                       TInputImage::ImageDimension);
00093 
00095   itkStaticConstMacro(BasisImageDimension, unsigned int,
00096                       TBasisImage::ImageDimension);
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);
00109 
00111   itkSetConstObjectMacro(MeanImage, BasisImageType);
00112   itkGetConstObjectMacro(MeanImage, BasisImageType);
00114 
00116   void SetBasisImages(const BasisImagePointerVector &);
00117 
00118   BasisImagePointerVector GetBasisImages() { return m_BasisImages; }
00119 
00121   typedef typename ImagePCAShapeModelEstimator< TInputImage,
00122                                                 TBasisImage >::Pointer ModelPointerType;
00123 
00125   void SetBasisFromModel(ModelPointerType model);
00126 
00128   void Compute(void);
00129 
00131   itkGetConstMacro(Projection, BasisVectorType);
00132 protected:
00133   ImagePCADecompositionCalculator();
00134   virtual ~ImagePCADecompositionCalculator() {}
00135   void PrintSelf(std::ostream & os, Indent indent) const;
00137 
00138   void CalculateBasisMatrix(void);
00139 
00140   void CalculateRecenteredImageAsVector(void);
00141 
00142 private:
00143   typedef typename BasisImageType::SizeType BasisSizeType;
00144 
00145   ImagePCADecompositionCalculator(const Self &); //purposely not implemented
00146   void operator=(const Self &);                  //purposely not implemented
00147 
00148   BasisVectorType         m_Projection;
00149   BasisVectorType         m_ImageAsVector;
00150   BasisImagePointerVector m_BasisImages;
00151   BasisImageConstPointer  m_MeanImage;
00152   BasisSizeType           m_Size;
00153   InputImageConstPointer  m_Image;
00154   BasisMatrixType         m_BasisMatrix;
00155   bool                    m_BasisMatrixCalculated;
00156   SizeValueType           m_NumPixels;
00157 };
00158 } // end namespace itk
00159 
00160 #ifndef ITK_MANUAL_INSTANTIATION
00161 #include "itkImagePCADecompositionCalculator.hxx"
00162 #endif
00163 
00164 #endif
00165