ITK  5.2.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  * 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, 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 
75 
77  using InputImageType = TInputImage;
78  using BasisImageType = TBasisImage;
79 
81  using InputImagePointer = typename TInputImage::Pointer;
82  using BasisImagePointer = typename TBasisImage::Pointer;
83 
85  using InputImageConstPointer = typename TInputImage::ConstPointer;
86  using BasisImageConstPointer = typename TBasisImage::ConstPointer;
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);
108 
110  itkSetConstObjectMacro(MeanImage, BasisImageType);
111  itkGetConstObjectMacro(MeanImage, BasisImageType);
113 
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 
144  void
145  CalculateBasisMatrix();
146 
147  void
148  CalculateRecenteredImageAsVector();
149 
150 private:
152 
162 };
163 } // end namespace itk
164 
165 #ifndef ITK_MANUAL_INSTANTIATION
166 # include "itkImagePCADecompositionCalculator.hxx"
167 #endif
168 
169 #endif
itk::ImagePCADecompositionCalculator::BasisSizeType
typename BasisImageType::SizeType BasisSizeType
Definition: itkImagePCADecompositionCalculator.h:151
itk::ImagePCADecompositionCalculator::BasisMatrixType
vnl_matrix< BasisPixelType > BasisMatrixType
Definition: itkImagePCADecompositionCalculator.h:101
itk::ImagePCADecompositionCalculator::m_Size
BasisSizeType m_Size
Definition: itkImagePCADecompositionCalculator.h:157
itk::ImagePCADecompositionCalculator::m_Image
InputImageConstPointer m_Image
Definition: itkImagePCADecompositionCalculator.h:158
itk::ImagePCADecompositionCalculator::BasisImagePointerVector
std::vector< BasisImagePointer > BasisImagePointerVector
Definition: itkImagePCADecompositionCalculator.h:98
itkImagePCAShapeModelEstimator.h
itk::ImagePCADecompositionCalculator::m_BasisMatrixCalculated
bool m_BasisMatrixCalculated
Definition: itkImagePCADecompositionCalculator.h:160
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::m_MeanImage
BasisImageConstPointer m_MeanImage
Definition: itkImagePCADecompositionCalculator.h:156
itk::ImagePCADecompositionCalculator::m_ImageAsVector
BasisVectorType m_ImageAsVector
Definition: itkImagePCADecompositionCalculator.h:154
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:59
itk::ImagePCADecompositionCalculator::m_BasisMatrix
BasisMatrixType m_BasisMatrix
Definition: itkImagePCADecompositionCalculator.h:159
itk::ImagePCADecompositionCalculator::m_Projection
BasisVectorType m_Projection
Definition: itkImagePCADecompositionCalculator.h:153
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:62
itk::ImagePCADecompositionCalculator::GetBasisImages
BasisImagePointerVector GetBasisImages()
Definition: itkImagePCADecompositionCalculator.h:119
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::ImagePCADecompositionCalculator::m_NumPixels
SizeValueType m_NumPixels
Definition: itkImagePCADecompositionCalculator.h:161
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ImagePCADecompositionCalculator::m_BasisImages
BasisImagePointerVector m_BasisImages
Definition: itkImagePCADecompositionCalculator.h:155