ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkVectorFieldPCA.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
19#ifndef itkVectorFieldPCA_h
20#define itkVectorFieldPCA_h
21
22#include "itkObject.h"
23#include "itkPointSet.h"
25#include "vnl/vnl_vector.h"
26#include "vnl/vnl_matrix.h"
27
28namespace itk
29{
30
53
54template <typename TRealValueType = double>
55class ITK_TEMPLATE_EXPORT GaussianDistanceKernel : public KernelFunctionBase<TRealValueType>
56{
57public:
63
65 itkOverrideGetNameOfClassMacro(GaussianDistanceKernel);
66
68 itkNewMacro(Self);
69
73 void
75 {
76 m_KernelSigma = s;
77 m_OneOverMinusTwoSigmaSqr = -1.0 / (2.0 * s * s);
78 }
79 itkGetMacro(KernelSigma, double);
80
84 TRealValueType
85 Evaluate(const TRealValueType & u) const override
86 {
87 return (std::exp(u * m_OneOverMinusTwoSigmaSqr));
88 }
89
90protected:
92 ~GaussianDistanceKernel() override = default;
93 void
94 PrintSelf(std::ostream & os, Indent indent) const override
95 {
96 Superclass::PrintSelf(os, indent);
97 }
98
99private:
100 double m_KernelSigma{ 1.0 };
102};
103
104template <typename TVectorFieldElementType,
105 typename TPCType,
106 typename TPointSetPixelType = float,
107 typename TPointSetCoordRepType = float,
108 typename KernelFunctionType = KernelFunctionBase<TPointSetCoordRepType>,
109 class TPointSetType =
110 PointSet<TPointSetPixelType, 3, DefaultStaticMeshTraits<TPointSetPixelType, 3, 3, TPointSetCoordRepType>>>
111class ITK_TEMPLATE_EXPORT VectorFieldPCA : public Object
112{
113public:
114 ITK_DISALLOW_COPY_AND_MOVE(VectorFieldPCA);
115
121
123 itkNewMacro(Self);
124
126 itkOverrideGetNameOfClassMacro(VectorFieldPCA);
127
129 using InputPointSetType = TPointSetType;
130
132 using InputPointType = typename InputPointSetType::PointType;
133
135 using PointsContainer = typename InputPointSetType::PointsContainer;
136 using PointsContainerIterator = typename PointsContainer::Iterator;
137
139 using InputPointSetPointer = typename InputPointSetType::Pointer;
140
142 using InputPointSetConstPointer = typename InputPointSetType::ConstPointer;
143
147 static constexpr unsigned int InputMeshDimension = TPointSetType::PointDimension;
148
150 using VectorFieldType = vnl_matrix<TVectorFieldElementType>;
152
155
157 using MatrixType = vnl_matrix<TPCType>;
158 using VectorType = vnl_vector<TPCType>;
159
162
164 using KernelFunctionPointer = typename KernelFunctionType::Pointer;
165
171
176 itkGetMacro(VectorFieldSet, VectorFieldSetTypePointer);
177
181 itkSetMacro(ComponentCount, unsigned int);
182 itkGetMacro(ComponentCount, unsigned int);
183
188
194 void
196
200 itkGetConstReferenceMacro(AveVectorField, MatrixType);
201 itkGetConstReferenceMacro(PCAEigenValues, VectorType);
202 itkGetConstObjectMacro(BasisVectors, BasisSetType);
203
204protected:
206 ~VectorFieldPCA() override = default;
207 void
208 PrintSelf(std::ostream & os, Indent indent) const override;
209
211 void
213
215 void
217
218private:
220
225
226 // Problem dimensions
227 unsigned int m_ComponentCount{ 0 };
228 unsigned int m_SetSize{ 0 };
229 unsigned int m_VectorDimCount{ 0 };
230 unsigned int m_PointDim{ 0 };
231
235
236 bool m_PCACalculated{ false };
237};
238
239} // end namespace itk
240
241#ifndef ITK_MANUAL_INSTANTIATION
242# include "itkVectorFieldPCA.hxx"
243#endif
244
245#endif
~GaussianDistanceKernel() override=default
void SetKernelSigma(double s)
Set and get the Kernel sigma.
KernelFunctionBase< TRealValueType > Superclass
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
TRealValueType Evaluate(const TRealValueType &u) const override
Evaluate the function. Input is the squared distance.
void PrintSelf(std::ostream &os, Indent indent) const override
GaussianDistanceKernel Self
Control indentation during Print() invocation.
Definition itkIndent.h:53
virtual void PrintSelf(std::ostream &os, Indent indent) const
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition itkPointSet.h:82
Implements transparent reference counting.
typename VectorFieldSetType::Pointer VectorFieldSetTypePointer
void PrintSelf(std::ostream &os, Indent indent) const override
typename InputPointSetType::ConstPointer InputPointSetConstPointer
vnl_matrix< TVectorFieldElementType > VectorFieldType
typename KernelFunctionType::Pointer KernelFunctionPointer
~VectorFieldPCA() override=default
vnl_vector< TPCType > VectorType
InputPointSetPointer m_PointSet
KernelFunctionPointer m_KernelFunction
VectorContainer< unsigned int, VectorFieldType > VectorFieldSetType
VectorContainer< unsigned int, VectorType > ResSetType
void Compute()
Compute the PCA decomposition of the input point set. If a Kernel and a Kernel Sigma are set ,...
SmartPointer< Self > Pointer
typename InputPointSetType::Pointer InputPointSetPointer
unsigned int m_ComponentCount
typename InputPointSetType::PointsContainer PointsContainer
TPointSetType InputPointSetType
typename InputPointSetType::PointType InputPointType
vnl_matrix< TPCType > MatrixType
static constexpr unsigned int InputMeshDimension
Input PointSet dimension.
unsigned int m_VectorDimCount
VectorFieldSetTypePointer m_VectorFieldSet
SmartPointer< const Self > ConstPointer
typename BasisSetType::Pointer BasisSetTypePointer
BasisSetTypePointer m_BasisVectors
typename PointsContainer::Iterator PointsContainerIterator
typename VectorFieldSetType::ConstPointer VectorFieldSetTypeConstPointer
VectorContainer< unsigned int, MatrixType > BasisSetType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
detail::VectorContainer< std::conditional_t< std::is_void_v< T2 >, SizeValueType, T1 >, std::conditional_t< std::is_void_v< T2 >, T1, T2 > > VectorContainer
#define itkSetMacro(name, type)