Fits a conic to a set of points using linear regression. More...
#include <vector>#include <iostream>#include <vnl/vnl_matrix_fixed.h>#include <vgl/vgl_point_2d.h>#include <vgl/vgl_homg_point_2d.h>#include <vgl/vgl_conic.h>#include <vgl/algo/vgl_norm_trans_2d.h>Go to the source code of this file.
Classes | |
| class | vgl_conic_2d_regression< T > |
Macros | |
| #define | VGL_CONIC_2D_REGRESSION_INSTANTIATE(T) extern "please include vgl/algo/vgl_conic_2d_regression.hxx first" |
Fits a conic to a set of points using linear regression.
Since conic fitting is rather ill-conditioned it is necessary to normalize the point coordinates so that they have equal standard deviations with respect to the center (mean) of the pointset. The points are transformed to have zero mean. The resulting conic is transformed back to the original frame for computing the Sampson approximation to fitting error.
The regression uses the Bookstein algorithm which constrains the conic norm,
, so that
With this normalization, the resulting fit is invariant up to a similarity transform of the pointset. The solution is formulated as an eigenvalue problem as follows:
The scatter matrix S is decomposed as
$ S = \begin{array}{cc} S_{11} & S_{12}
\\ S_{21} & S_{22} \end{array}$
note \f$S_{21} = S_{12}^t\f$
The conic coefficients are \f$v_1 = \{a,b,c\}^t\f$ and \f$v_2 = \{d,e,f\}^t\f$
The Bookstein constraint is expressed by the diagonal matrix
D = Diag{1, 0.5, 1, 0, 0, 0}
The Lagrangian to be minimized is
$ L = v_1^t S_{11} v_1 + 2 v_2^t S_{21} v_1 + v_2^t S_{22} v_2
- \lambda(v_1^t D v_1 -2) $.
Minimizing with respect to v2 gives
\f$ dL/dv_2 = 2 S_{21} v_1 + 2 S_{22} v_2 = 0 \f$
So, \f$ v_2 = -S_{22}^-1 S_{21} v_1 \f$.
Substituting for v2 in L,
$ L = v_1^t ( S_{11} - S_{12} * S_{22}^-1 * S_{21}) v_1 - \lambda(v_1^t D v_1 -2) = v_1^t ( (S_{11} - S_{12} * S_{22}^-1 * S_{21}) - \lambda D ) v_1 - 2 \lambda $,
.
So,
.
This eigenvalue problem is solved using singular value decomposition.
Modifications none
Definition in file vgl_conic_2d_regression.h.
| #define VGL_CONIC_2D_REGRESSION_INSTANTIATE | ( | T | ) | extern "please include vgl/algo/vgl_conic_2d_regression.hxx first" |
Definition at line 149 of file vgl_conic_2d_regression.h.
1.8.15