ITK  5.0.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:
81  ITK_DISALLOW_COPY_AND_ASSIGN(ImagePCAShapeModelEstimator);
82 
88 
90  itkNewMacro(Self);
91 
94 
96  using InputImageType = TInputImage;
97  using InputImagePointer = typename TInputImage::Pointer;
98  using InputImageConstPointer = typename TInputImage::ConstPointer;
99 
101  using InputImagePixelType = typename TInputImage::PixelType;
102 
106 
108  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
109 
111  using OutputImageType = TOutputImage;
112  using OutputImagePointer = typename TOutputImage::Pointer;
113 
116 
118  using MatrixOfDoubleType = vnl_matrix< double >;
119 
121  using MatrixOfIntegerType = vnl_matrix< int >;
122 
124  using VectorOfDoubleType = vnl_vector< double >;
125 
130  virtual void SetNumberOfPrincipalComponentsRequired(unsigned int n);
131 
132  itkGetConstMacro(NumberOfPrincipalComponentsRequired, unsigned int);
133 
135  virtual void SetNumberOfTrainingImages(unsigned int n);
136 
137  itkGetConstMacro(NumberOfTrainingImages, unsigned int);
138 
140  itkGetConstMacro(EigenValues, VectorOfDoubleType);
141 
142 protected:
144  ~ImagePCAShapeModelEstimator() override = default;
145  void PrintSelf(std::ostream & os, Indent indent) const override;
146 
150  void EnlargeOutputRequestedRegion(DataObject *) override;
151 
156  void GenerateInputRequestedRegion() override;
157 
159  void GenerateData() override;
160 
161 private:
162 
164  using InputImagePointerArray = std::vector< InputImageConstPointer >;
165  using InputImageIteratorArray = std::vector< InputImageConstIterator >;
166 
168 
170  using InputPixelType = typename TInputImage::PixelType;
171 
180  void EstimateShapeModels() override;
181 
182  void EstimatePCAShapeModelParameters();
183 
184  void CalculateInnerProduct();
185 
188 
190 
192 
194 
196 
198 
200 
201  unsigned int m_NumberOfPixels{0};
202 
203  // The number of input images for PCA
204  unsigned int m_NumberOfTrainingImages{0};
205 
206  // The number of output Principal Components
208 }; // class ImagePCAShapeModelEstimator
209 } // namespace itk
210 
211 #ifndef ITK_MANUAL_INSTANTIATION
212 #include "itkImagePCAShapeModelEstimator.hxx"
213 #endif
214 
215 #endif
typename OutputImageType::Pointer OutputImagePointer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
std::vector< InputImageConstPointer > InputImagePointerArray
typename InputImageType::PixelType InputImagePixelType
typename TInputImage::SizeType ImageSizeType
Base class for ImagePCAShapeModelEstimator object.
typename InputImageType::Pointer InputImagePointer
A multi-dimensional iterator templated over image type that walks a region of pixels.
TOutputImage OutputImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
std::vector< InputImageConstIterator > InputImageIteratorArray
typename InputImageType::ConstPointer InputImageConstPointer
Base class for statistical shape model estimation.
Base class for all data objects in ITK.
typename TInputImage::PixelType InputPixelType
A multi-dimensional iterator templated over image type that walks a region of pixels.