ITK  4.13.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 
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
83  { return ( vcl_exp( u * m_OneOverMinusTwoSigmaSqr )); }
84 
85 protected:
88  void PrintSelf(std::ostream& os, Indent indent) const
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:
113 
115  itkNewMacro(Self);
116 
118  itkTypeMacro(VectorFieldPCA, Object);
119 
121  typedef TPointSetType InputPointSetType;
122 
125 
127  typedef typename InputPointSetType::PointsContainer PointsContainer;
128  typedef typename PointsContainer::Iterator PointsContainerIterator;
129 
131  typedef typename InputPointSetType::Pointer InputPointSetPointer;
132 
134  typedef typename InputPointSetType::ConstPointer InputPointSetConstPointer;
135 
139  itkStaticConstMacro(InputMeshDimension, unsigned int,
140  TPointSetType::PointDimension);
141 
143  typedef vnl_matrix< TVectorFieldElementType > VectorFieldType;
145 
148 
150  typedef vnl_matrix< TPCType > MatrixType;
151  typedef vnl_vector< TPCType > VectorType;
152 
155 
157  typedef typename KernelFunctionType::Pointer KernelFunctionPointer;
158 
162  itkSetMacro(PointSet, InputPointSetPointer);
163  itkGetMacro(PointSet, InputPointSetPointer);
165 
169  itkSetMacro(VectorFieldSet, VectorFieldSetTypePointer);
170  itkGetMacro(VectorFieldSet, VectorFieldSetTypePointer);
172 
176  itkSetMacro( ComponentCount, unsigned int );
177  itkGetMacro( ComponentCount, unsigned int );
179 
183  itkSetMacro( KernelFunction, KernelFunctionPointer );
184 
190  void Compute(void);
191 
195  itkGetConstReferenceMacro(AveVectorField, MatrixType);
196  itkGetConstReferenceMacro(PCAEigenValues, VectorType);
197  itkGetConstObjectMacro(BasisVectors, BasisSetType);
199 
200 protected:
201  VectorFieldPCA();
202  virtual ~VectorFieldPCA() {};
203  void PrintSelf(std::ostream& os, Indent indent) const;
204 
205  void KernelPCA(void);
206  void computeMomentumSCP(void);
207 
208 private:
209 
210  VectorFieldPCA(const Self&); //purposely not implemented
211  void operator=(const Self&); //purposely not implemented
212 
214 
219 
220  // problem dimensions
221  unsigned int m_ComponentCount;
222  unsigned int m_SetSize;
223  unsigned int m_VectorDimCount;
224  unsigned int m_VertexCount;
225  unsigned int m_PointDim;
226 
230 
232 
233 };
234 
235 } // end namespace itk
236 
237 #include "itkVectorFieldPCA.hxx"
238 
239 #endif
unsigned int m_ComponentCount
SmartPointer< Self > Pointer
Light weight base class for most itk classes.
double Evaluate(const double &u) const
Evaluate the function. Input is the squared distance.
SmartPointer< Self > Pointer
InputPointSetPointer m_PointSet
void PrintSelf(std::ostream &os, Indent indent) const
Produce the principle components of a vector valued function.
InputPointSetType::ConstPointer InputPointSetConstPointer
VectorContainer< unsigned int, VectorType > ResSetType
VectorFieldSetType::ConstPointer VectorFieldSetTypeConstPointer
Kernel used for density estimation and nonparameteric regression.
BasisSetType::Pointer BasisSetTypePointer
KernelFunctionBase< TRealValueType > Superclass
VectorContainer< unsigned int, MatrixType > BasisSetType
unsigned int m_VectorDimCount
vnl_matrix< TVectorFieldElementType > VectorFieldType
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
KernelFunction is for backward compatibility with ITKv3.
PointsContainer::Iterator PointsContainerIterator
TPointSetType InputPointSetType
VectorFieldSetType::Pointer VectorFieldSetTypePointer
SmartPointer< const Self > ConstPointer
SmartPointer< const Self > ConstPointer
VectorContainer< unsigned int, VectorFieldType > VectorFieldSetType
KernelFunctionPointer m_KernelFunction
InputPointSetType::Pointer InputPointSetPointer
InputPointSetType::PointType InputPointType
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
GaussianDistanceKernel Self
BasisSetTypePointer m_BasisVectors
KernelFunctionType::Pointer KernelFunctionPointer
void SetKernelSigma(double s)
Set and get the Kernel sigma.
vnl_vector< TPCType > VectorType
vnl_matrix< TPCType > MatrixType
Base class for most ITK classes.
Definition: itkObject.h:59
InputPointSetType::PointsContainer PointsContainer