ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkImagePCAShapeModelEstimator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkImagePCAShapeModelEstimator_h
19 #define __itkImagePCAShapeModelEstimator_h
20 
21 #include <ctime>
22 #include <cmath>
23 #include <cfloat>
24 
25 #include "vnl/vnl_vector.h"
26 #include "vnl/vnl_matrix.h"
27 #include "vnl/vnl_math.h"
28 #include "vnl/algo/vnl_matrix_inverse.h"
29 
30 #include "itkImageRegionIterator.h"
31 #include "itkMacro.h"
32 
34 #include "itkConceptChecking.h"
35 #include "itkImage.h"
36 #include "vnl/algo/vnl_generalized_eigensystem.h"
37 #include "vnl/algo/vnl_symmetric_eigensystem.h"
38 
39 namespace itk
40 {
75 template< class TInputImage,
76  class TOutputImage = Image< double, TInputImage::ImageDimension > >
77 class ITK_EXPORT ImagePCAShapeModelEstimator:
78  public ImageShapeModelEstimatorBase< TInputImage, TOutputImage >
79 {
80 public:
86 
88  itkNewMacro(Self);
89 
92 
94  typedef TInputImage InputImageType;
95  typedef typename TInputImage::Pointer InputImagePointer;
96  typedef typename TInputImage::ConstPointer InputImageConstPointer;
97 
99  typedef typename TInputImage::PixelType InputImagePixelType;
100 
104 
106  itkStaticConstMacro(InputImageDimension, unsigned int,
107  TInputImage::ImageDimension);
108 
110  typedef TOutputImage OutputImageType;
111  typedef typename TOutputImage::Pointer OutputImagePointer;
112 
115 
117  typedef vnl_matrix< double > MatrixOfDoubleType;
118 
120  typedef vnl_matrix< int > MatrixOfIntegerType;
121 
123  typedef vnl_vector< double > VectorOfDoubleType;
124 
129  virtual void SetNumberOfPrincipalComponentsRequired(unsigned int n);
130 
131  itkGetConstMacro(NumberOfPrincipalComponentsRequired, unsigned int);
132 
134  virtual void SetNumberOfTrainingImages(unsigned int n);
135 
136  itkGetConstMacro(NumberOfTrainingImages, unsigned int);
137 
139  itkGetConstMacro(EigenValues, VectorOfDoubleType);
140 
141 protected:
144  virtual void PrintSelf(std::ostream & os, Indent indent) const;
145 
149  virtual void EnlargeOutputRequestedRegion(DataObject *);
150 
155  virtual void GenerateInputRequestedRegion();
156 
158  void GenerateData();
159 
160 private:
161 
162  ImagePCAShapeModelEstimator(const Self &); //purposely not implemented
163  void operator=(const Self &); //purposely not implemented
164 
166  typedef std::vector< InputImageConstPointer > InputImagePointerArray;
167  typedef std::vector< InputImageConstIterator > InputImageIteratorArray;
168 
169  typedef typename TInputImage::SizeType ImageSizeType;
170 
172  typedef typename TInputImage::PixelType InputPixelType;
173 
182  virtual void EstimateShapeModels();
183 
184  void EstimatePCAShapeModelParameters();
185 
186  void CalculateInnerProduct();
187 
190 
192 
194 
196 
198 
200 
202 
203  unsigned int m_NumberOfPixels;
204 
205  // The number of input images for PCA
207 
208  // The number of output Principal Components
210 }; // class ImagePCAShapeModelEstimator
211 } // namespace itk
212 
213 #ifndef ITK_MANUAL_INSTANTIATION
214 #include "itkImagePCAShapeModelEstimator.hxx"
215 #endif
216 
217 #endif
218