Image Component Library (ICL)
LeastSquareModelFitting2D.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMath/src/ICLMath/LeastSquareModelFitting2D.h **
10 ** Module : ICLMath **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
35 #include <ICLUtils/Point32f.h>
36 
37 namespace icl{
38  namespace math{
39 
41 
43  class LeastSquareModelFitting2D : public LeastSquareModelFitting<double,utils::Point32f>{
46  public:
49 
52  DynMatrix<double> *constraintMatrix = 0):
53  Super(modelDim,gen,constraintMatrix){}
54 
56 
57  static inline void line_gen(const utils::Point32f &p, double *d){
58  d[0] = p.x;
59  d[1] = p.y;
60  d[2] = 1;
61  }
62 
64 
65  static inline void circle_gen(const utils::Point32f &p, double *d){
66  d[0] = utils::sqr(p.x) + utils::sqr(p.y);
67  d[1] = p.x;
68  d[2] = p.y;
69  d[3] = 1;
70  }
71 
73 
74  static inline void restr_ellipse_gen(const utils::Point32f &p, double *d){
75  d[0] = utils::sqr(p.x);
76  d[1] = utils::sqr(p.y);
77  d[2] = p.x;
78  d[3] = p.y;
79  d[4] = 1;
80  }
81 
83 
84  static inline void ellipse_gen(const utils::Point32f &p, double *d){
85  d[0] = utils::sqr(p.x);
86  d[1] = p.x * p.y;
87  d[2] = utils::sqr(p.y);
88  d[3] = p.x;
89  d[4] = p.y;
90  d[5] = 1;
91  }
92 
93  inline std::vector<double> fit(const std::vector<utils::Point32f> &points){
94  return Super::fit(points);
95  }
96  inline icl64f getError(const std::vector<double> &model, const utils::Point32f &p) {
97  return Super::getError(model,p);
98  }
99  };
100 
101 
102  } // namespace math
103 }
104 
undocument this line if you encounter any issues!
Definition: Any.h:37
LeastSquareModelFitting2D(int modelDim, DesignMatrixGen gen, DynMatrix< double > *constraintMatrix=0)
Constructor with given parameters.
Definition: LeastSquareModelFitting2D.h:51
float y
y position of this point
Definition: Point32f.h:48
icl64f getError(const Model &model, const utils::Point32f &p)
computes the error for a given data point
Definition: LeastSquareModelFitting.h:175
Direct Least Square Fitting Algorithm.
Definition: LeastSquareModelFitting.h:135
LeastSquareModelFitting< double, utils::Point32f > Super
super type
Definition: LeastSquareModelFitting2D.h:45
Direct Least Square Fitting specialization for 2D input data.
Definition: LeastSquareModelFitting2D.h:43
Model fit(const std::vector< utils::Point32f > &points)
fits the model to the given data points and returns optimal parameter set
Definition: LeastSquareModelFitting.h:187
icl64f getError(const std::vector< double > &model, const utils::Point32f &p)
Definition: LeastSquareModelFitting2D.h:96
Ipp64f icl64f
64Bit floating point type for the ICL
Definition: BasicTypes.h:52
static T sqr(const T &x)
square template (faster than pow(x,2)
Definition: Macros.h:212
LeastSquareModelFitting2D()
Default constructor for creating dummy instances.
Definition: LeastSquareModelFitting2D.h:48
std::vector< double > fit(const std::vector< utils::Point32f > &points)
Definition: LeastSquareModelFitting2D.h:93
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
static void line_gen(const utils::Point32f &p, double *d)
DesignMatrixGenerator for the 3-parameter line model.
Definition: LeastSquareModelFitting2D.h:57
float x
x position of this point
Definition: Point32f.h:45
static void circle_gen(const utils::Point32f &p, double *d)
DesignMatrixGenerator for the 4 parameter circle model.
Definition: LeastSquareModelFitting2D.h:65
static void ellipse_gen(const utils::Point32f &p, double *d)
DesignMatrixGenerator for the 6 parameter general ellipse model.
Definition: LeastSquareModelFitting2D.h:84
static void restr_ellipse_gen(const utils::Point32f &p, double *d)
DesignMatrixGenerator for the 5 parameter restricted ellipse model.
Definition: LeastSquareModelFitting2D.h:74