ITK  5.4.0
Insight Toolkit
itkImagePCADecompositionCalculator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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, typename TBasisImage = Image<double, TInputImage::ImageDimension>>
59 class ITK_TEMPLATE_EXPORT ImagePCADecompositionCalculator : public Object
60 {
61 public:
62  ITK_DISALLOW_COPY_AND_MOVE(ImagePCADecompositionCalculator);
63 
66  using Superclass = Object;
69 
71  itkNewMacro(Self);
72 
74  itkOverrideGetNameOfClassMacro(ImagePCADecompositionCalculator);
75 
77  using InputImageType = TInputImage;
78  using BasisImageType = TBasisImage;
79 
83 
87 
89  using BasisPixelType = typename TBasisImage::PixelType;
90 
92  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
93 
95  static constexpr unsigned int BasisImageDimension = TBasisImage::ImageDimension;
96 
98  using BasisImagePointerVector = std::vector<BasisImagePointer>;
99 
101  using BasisMatrixType = vnl_matrix<BasisPixelType>;
102  using BasisVectorType = vnl_vector<BasisPixelType>;
103 
105  itkSetConstObjectMacro(Image, InputImageType);
106  itkGetConstObjectMacro(Image, InputImageType);
110  itkSetConstObjectMacro(MeanImage, BasisImageType);
111  itkGetConstObjectMacro(MeanImage, BasisImageType);
115  void
116  SetBasisImages(const BasisImagePointerVector &);
117 
120  {
121  return m_BasisImages;
122  }
123 
126 
128  void
129  SetBasisFromModel(ModelPointerType model);
130 
132  void
133  Compute();
134 
136  itkGetConstMacro(Projection, BasisVectorType);
137 
138 protected:
140  ~ImagePCADecompositionCalculator() override = default;
141  void
142  PrintSelf(std::ostream & os, Indent indent) const override;
143 
145  void
146  CalculateBasisMatrix();
147 
149  void
150  CalculateRecenteredImageAsVector();
151 
152 private:
154 
155  BasisVectorType m_Projection{};
156  BasisVectorType m_ImageAsVector{};
157  BasisImagePointerVector m_BasisImages{};
158  BasisImageConstPointer m_MeanImage{};
159  BasisSizeType m_Size{};
161  BasisMatrixType m_BasisMatrix{};
162  bool m_BasisMatrixCalculated{};
163  SizeValueType m_NumPixels{};
164 };
165 } // end namespace itk
166 
167 #ifndef ITK_MANUAL_INSTANTIATION
168 # include "itkImagePCADecompositionCalculator.hxx"
169 #endif
170 
171 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::ImagePCADecompositionCalculator::BasisSizeType
typename BasisImageType::SizeType BasisSizeType
Definition: itkImagePCADecompositionCalculator.h:153
itk::ImagePCADecompositionCalculator::BasisMatrixType
vnl_matrix< BasisPixelType > BasisMatrixType
Definition: itkImagePCADecompositionCalculator.h:101
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::ImagePCADecompositionCalculator::BasisImagePointerVector
std::vector< BasisImagePointer > BasisImagePointerVector
Definition: itkImagePCADecompositionCalculator.h:98
itkImagePCAShapeModelEstimator.h
itk::ImagePCADecompositionCalculator::BasisImagePointer
typename TBasisImage::Pointer BasisImagePointer
Definition: itkImagePCADecompositionCalculator.h:82
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImagePCADecompositionCalculator::BasisPixelType
typename TBasisImage::PixelType BasisPixelType
Definition: itkImagePCADecompositionCalculator.h:89
itk::ImagePCADecompositionCalculator::InputImagePointer
typename TInputImage::Pointer InputImagePointer
Definition: itkImagePCADecompositionCalculator.h:81
itk::ImagePCADecompositionCalculator::BasisImageConstPointer
typename TBasisImage::ConstPointer BasisImageConstPointer
Definition: itkImagePCADecompositionCalculator.h:86
itk::ImagePCADecompositionCalculator::InputImageType
TInputImage InputImageType
Definition: itkImagePCADecompositionCalculator.h:77
itk::ImagePCADecompositionCalculator::BasisImageType
TBasisImage BasisImageType
Definition: itkImagePCADecompositionCalculator.h:78
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::ImagePCADecompositionCalculator
Decomposes an image into directions along basis components.
Definition: itkImagePCADecompositionCalculator.h:59
itk::ImagePCADecompositionCalculator::BasisVectorType
vnl_vector< BasisPixelType > BasisVectorType
Definition: itkImagePCADecompositionCalculator.h:102
itkObject.h
itk::ImagePCADecompositionCalculator::InputImageConstPointer
typename TInputImage::ConstPointer InputImageConstPointer
Definition: itkImagePCADecompositionCalculator.h:85
itk::ImagePCADecompositionCalculator::ModelPointerType
typename ImagePCAShapeModelEstimator< TInputImage, TBasisImage >::Pointer ModelPointerType
Definition: itkImagePCADecompositionCalculator.h:125
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::ImagePCADecompositionCalculator::GetBasisImages
BasisImagePointerVector GetBasisImages()
Definition: itkImagePCADecompositionCalculator.h:119
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83