Statismo  0.10.1
 All Classes Namespaces Functions Typedefs
Kernels.h
1 
13 #ifndef __KERNELS_H
14 #define __KERNELS_H
15 
16 #include <cmath>
17 
18 #include <vector>
19 #include <memory>
20 #include <functional>
21 
22 #include "CommonTypes.h"
23 #include "Config.h"
24 #include "ModelInfo.h"
25 #include "Representer.h"
26 #include "StatisticalModel.h"
27 
28 
29 namespace statismo {
30 
34 template<class TPoint>
36  public:
37 
42 
43  virtual ~ScalarValuedKernel() {
44  }
45 
49  virtual double operator()(const TPoint& x, const TPoint& y) const = 0;
50 
54  virtual std::string GetKernelInfo() const = 0;
55 
56 };
57 
58 
62 template<class TPoint>
64  public:
65 
69  MatrixValuedKernel(unsigned dim) :
70  m_dimension(dim) {
71  }
72 
76  virtual MatrixType operator()(const TPoint& x,
77  const TPoint& y) const = 0;
78 
82  virtual unsigned GetDimension() const {
83  return m_dimension;
84  }
85  ;
86  virtual ~MatrixValuedKernel() {
87  }
88 
92  virtual std::string GetKernelInfo() const = 0;
93 
94  protected:
95  unsigned m_dimension;
96 
97 };
98 
99 template<class T>
100 class StatisticalModelKernel: public MatrixValuedKernel<typename Representer<T>::PointType > {
101  public:
102 
103  typedef Representer<T> RepresenterType;
104  typedef typename RepresenterType::PointType PointType;
105  typedef StatisticalModel<T> StatisticalModelType;
106 
107  StatisticalModelKernel(const StatisticalModelType* model) :
108  MatrixValuedKernel<PointType>(model->GetRepresenter()->GetDimensions()), m_statisticalModel(model) {
109  }
110 
111  virtual ~StatisticalModelKernel() {
112  }
113 
114  inline MatrixType operator()(const PointType& x, const PointType& y) const {
115  MatrixType m = m_statisticalModel->GetCovarianceAtPoint(x, y);
116  return m;
117  }
118 
119  std::string GetKernelInfo() const {
120  return "StatisticalModelKernel";
121  }
122 
123  private:
124  const StatisticalModelType* m_statisticalModel;
125 };
126 
127 
128 
129 } // namespace statismo
130 
131 #endif // __KERNELS_H
virtual double operator()(const TPoint &x, const TPoint &y) const =0
virtual unsigned GetDimension() const
Definition: Kernels.h:82
virtual MatrixType operator()(const TPoint &x, const TPoint &y) const =0
Definition: Kernels.h:63
A trivial representer, that does no representation at all, but works directly with vectorial data...
Definition: TrivialVectorialRepresenter.h:83
virtual std::string GetKernelInfo() const =0
Definition: Kernels.h:35
MatrixValuedKernel(unsigned dim)
Definition: Kernels.h:69
ScalarValuedKernel()
Definition: Kernels.h:41
virtual std::string GetKernelInfo() const =0
ITK Wrapper for the statismo::StatisticalModel class.
Definition: itkStatisticalModel.h:62