ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkImagePCADecompositionCalculator.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 itkImagePCADecompositionCalculator_h
19 #define itkImagePCADecompositionCalculator_h
20 
21 #include "itkObject.h"
23 #include "vnl/vnl_vector.h"
24 #include "vnl/vnl_matrix.h"
25 
26 namespace itk
27 {
58 template< typename TInputImage,
59  typename TBasisImage = Image< double, TInputImage::ImageDimension > >
60 class ITK_TEMPLATE_EXPORT ImagePCADecompositionCalculator:public Object
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_ASSIGN(ImagePCADecompositionCalculator);
64 
67  using Superclass = Object;
70 
72  itkNewMacro(Self);
73 
76 
78  using InputImageType = TInputImage;
79  using BasisImageType = TBasisImage;
80 
82  using InputImagePointer = typename TInputImage::Pointer;
83  using BasisImagePointer = typename TBasisImage::Pointer;
84 
86  using InputImageConstPointer = typename TInputImage::ConstPointer;
87  using BasisImageConstPointer = typename TBasisImage::ConstPointer;
88 
90  using BasisPixelType = typename TBasisImage::PixelType;
91 
93  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
94 
96  static constexpr unsigned int BasisImageDimension = TBasisImage::ImageDimension;
97 
99  using BasisImagePointerVector = std::vector< BasisImagePointer >;
100 
102  using BasisMatrixType = vnl_matrix< BasisPixelType >;
103  using BasisVectorType = vnl_vector< BasisPixelType >;
104 
106  itkSetConstObjectMacro(Image, InputImageType);
107  itkGetConstObjectMacro(Image, InputImageType);
109 
111  itkSetConstObjectMacro(MeanImage, BasisImageType);
112  itkGetConstObjectMacro(MeanImage, BasisImageType);
114 
116  void SetBasisImages(const BasisImagePointerVector &);
117 
118  BasisImagePointerVector GetBasisImages() { return m_BasisImages; }
119 
121  using ModelPointerType = typename ImagePCAShapeModelEstimator< TInputImage,
122  TBasisImage >::Pointer;
123 
125  void SetBasisFromModel(ModelPointerType model);
126 
128  void Compute();
129 
131  itkGetConstMacro(Projection, BasisVectorType);
132 
133 protected:
135  ~ImagePCADecompositionCalculator() override = default;
136  void PrintSelf(std::ostream & os, Indent indent) const override;
137 
138  void CalculateBasisMatrix();
139 
140  void CalculateRecenteredImageAsVector();
141 
142 private:
144 
154 };
155 } // end namespace itk
156 
157 #ifndef ITK_MANUAL_INSTANTIATION
158 #include "itkImagePCADecompositionCalculator.hxx"
159 #endif
160 
161 #endif
Light weight base class for most itk classes.
typename TBasisImage::ConstPointer BasisImageConstPointer
Decomposes an image into directions along basis components.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
std::vector< BasisImagePointer > BasisImagePointerVector
Base class for ImagePCAShapeModelEstimator object.
typename TInputImage::ConstPointer InputImageConstPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:60
Templated n-dimensional image class.
Definition: itkImage.h:75
typename ImagePCAShapeModelEstimator< TInputImage, TBasisImage >::Pointer ModelPointerType