ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVectorFieldPCA.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 
19 #ifndef itkVectorFieldPCA_h
20 #define itkVectorFieldPCA_h
21 
22 #include "itkObject.h"
23 #include "itkPointSet.h"
24 #include "itkKernelFunctionBase.h"
25 #include "vnl/vnl_vector.h"
26 #include "vnl/vnl_matrix.h"
27 
28 namespace itk
29 {
30 
54 template< typename TRealValueType = double >
55 class ITK_EXPORT GaussianDistanceKernel : public KernelFunctionBase<TRealValueType>
56 {
57 public:
63 
65  itkTypeMacro(GaussianDistanceKernel, KernelFunction);
66 
68  itkNewMacro(Self);
69 
73  void SetKernelSigma( double s )
74  { m_KernelSigma = s;
75  m_OneOverMinusTwoSigmaSqr = -1.0 / (2.0 * s * s); }
76  itkGetMacro( KernelSigma, double );
78 
82  inline double Evaluate (const double& u) const override
83  { return ( std::exp( u * m_OneOverMinusTwoSigmaSqr )); }
84 
85 protected:
88  void PrintSelf(std::ostream& os, Indent indent) const override
89  { Superclass::PrintSelf( os, indent ); }
90 
91 private:
92  double m_KernelSigma;
94 
95 };
96 
97 template <
98  typename TVectorFieldElementType,
99  typename TPCType,
100  typename TPointSetPixelType = float,
101  typename TPointSetCoordRepType = float,
102  typename KernelFunctionType = KernelFunctionBase<TPointSetCoordRepType>,
104  >
105 class ITK_EXPORT VectorFieldPCA : public Object
106 {
107 public:
108  ITK_DISALLOW_COPY_AND_ASSIGN(VectorFieldPCA);
109 
115 
117  itkNewMacro(Self);
118 
120  itkTypeMacro(VectorFieldPCA, Object);
121 
123  using InputPointSetType = TPointSetType;
124 
127 
129  using PointsContainer = typename InputPointSetType::PointsContainer;
130  using PointsContainerIterator = typename PointsContainer::Iterator;
131 
133  using InputPointSetPointer = typename InputPointSetType::Pointer;
134 
136  using InputPointSetConstPointer = typename InputPointSetType::ConstPointer;
137 
141  itkStaticConstMacro(InputMeshDimension, unsigned int,
142  TPointSetType::PointDimension);
143 
145  using VectorFieldType = vnl_matrix< TVectorFieldElementType >;
147 
150 
152  using MatrixType = vnl_matrix< TPCType >;
153  using VectorType = vnl_vector< TPCType >;
154 
157 
159  using KernelFunctionPointer = typename KernelFunctionType::Pointer;
160 
164  itkSetMacro(PointSet, InputPointSetPointer);
165  itkGetMacro(PointSet, InputPointSetPointer);
167 
171  itkSetMacro(VectorFieldSet, VectorFieldSetTypePointer);
172  itkGetMacro(VectorFieldSet, VectorFieldSetTypePointer);
174 
178  itkSetMacro( ComponentCount, unsigned int );
179  itkGetMacro( ComponentCount, unsigned int );
181 
185  itkSetMacro( KernelFunction, KernelFunctionPointer );
186 
192  void Compute(void);
193 
197  itkGetConstReferenceMacro(AveVectorField, MatrixType);
198  itkGetConstReferenceMacro(PCAEigenValues, VectorType);
199  itkGetConstObjectMacro(BasisVectors, BasisSetType);
201 
202 protected:
203  VectorFieldPCA();
204  ~VectorFieldPCA() override {};
205  void PrintSelf(std::ostream& os, Indent indent) const override;
206 
208  void KernelPCA();
209 
211  void ComputeMomentumSCP();
212 
213 private:
215 
220 
221  // Problem dimensions
222  unsigned int m_ComponentCount;
223  unsigned int m_SetSize;
224  unsigned int m_VectorDimCount;
225  unsigned int m_VertexCount;
226  unsigned int m_PointDim;
227 
231 
233 
234 };
235 
236 } // end namespace itk
237 
238 #ifndef ITK_MANUAL_INSTANTIATION
239 #include "itkVectorFieldPCA.hxx"
240 #endif
241 
242 #endif
unsigned int m_ComponentCount
typename KernelFunctionType::Pointer KernelFunctionPointer
typename VectorFieldSetType::Pointer VectorFieldSetTypePointer
void PrintSelf(std::ostream &os, Indent indent) const override
Light weight base class for most itk classes.
typename InputPointSetType::ConstPointer InputPointSetConstPointer
InputPointSetPointer m_PointSet
Produce the principle components of a vector valued function.
double Evaluate(const double &u) const override
Evaluate the function. Input is the squared distance.
typename VectorFieldSetType::ConstPointer VectorFieldSetTypeConstPointer
Kernel used for density estimation and nonparameteric regression.
unsigned int m_VectorDimCount
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
vnl_matrix< TPCType > MatrixType
vnl_matrix< TVectorFieldElementType > VectorFieldType
typename InputPointSetType::Pointer InputPointSetPointer
KernelFunctionPointer m_KernelFunction
TPointSetType InputPointSetType
typename InputPointSetType::PointType InputPointType
typename PointsContainer::Iterator PointsContainerIterator
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
VectorFieldSetTypePointer m_VectorFieldSet
unsigned int m_VertexCount
Control indentation during Print() invocation.
Definition: itkIndent.h:49
BasisSetTypePointer m_BasisVectors
typename InputPointSetType::PointsContainer PointsContainer
void SetKernelSigma(double s)
Set and get the Kernel sigma.
vnl_vector< TPCType > VectorType
Base class for most ITK classes.
Definition: itkObject.h:60
typename BasisSetType::Pointer BasisSetTypePointer