ITK  4.13.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 "itkMath.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< typename TInputImage,
76  typename TOutputImage = Image< double, TInputImage::ImageDimension > >
77 class ITK_TEMPLATE_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:
143  ~ImagePCAShapeModelEstimator() ITK_OVERRIDE;
144  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
145 
149  virtual void EnlargeOutputRequestedRegion(DataObject *) ITK_OVERRIDE;
150 
155  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
156 
158  void GenerateData() ITK_OVERRIDE;
159 
160 private:
161 
162  ITK_DISALLOW_COPY_AND_ASSIGN(ImagePCAShapeModelEstimator);
163 
165  typedef std::vector< InputImageConstPointer > InputImagePointerArray;
167 
168  typedef typename TInputImage::SizeType ImageSizeType;
169 
171  typedef typename TInputImage::PixelType InputPixelType;
172 
181  virtual void EstimateShapeModels() ITK_OVERRIDE;
182 
183  void EstimatePCAShapeModelParameters();
184 
185  void CalculateInnerProduct();
186 
188  InputImageIteratorArray m_InputImageIteratorArray;
189 
191 
192  MatrixOfDoubleType m_InnerProduct;
193 
194  MatrixOfDoubleType m_EigenVectors;
195 
196  VectorOfDoubleType m_EigenValues;
197 
198  VectorOfDoubleType m_EigenVectorNormalizedEnergy;
199 
200  ImageSizeType m_InputImageSize;
201 
202  unsigned int m_NumberOfPixels;
203 
204  // The number of input images for PCA
205  unsigned int m_NumberOfTrainingImages;
206 
207  // The number of output Principal Components
208  unsigned int m_NumberOfPrincipalComponentsRequired;
209 }; // class ImagePCAShapeModelEstimator
210 } // namespace itk
211 
212 #ifndef ITK_MANUAL_INSTANTIATION
213 #include "itkImagePCAShapeModelEstimator.hxx"
214 #endif
215 
216 #endif
InputImageType::ConstPointer InputImageConstPointer
ImageRegionIterator< TOutputImage > OutputImageIterator
ImageRegionIterator< TInputImage > InputImageIterator
Base class for all process objects that output image data.
ImageShapeModelEstimatorBase< TInputImage, TOutputImage > Superclass
Base class for ImagePCAShapeModelEstimator object.
A multi-dimensional iterator templated over image type that walks a region of pixels.
ImageRegionConstIterator< TInputImage > InputImageConstIterator
Control indentation during Print() invocation.
Definition: itkIndent.h:49
std::vector< InputImageConstIterator > InputImageIteratorArray
std::vector< InputImageConstPointer > InputImagePointerArray
Base class for statistical shape model estimation.
Base class for all data objects in ITK.
A multi-dimensional iterator templated over image type that walks a region of pixels.