Public Member Functions | Private Attributes | List of all members
vgl_line_2d_regression< T > Class Template Reference

A class to hold the line 2d_regression data and actual fitting code. More...

#include <vgl_algo_fwd.h>

Public Member Functions

 vgl_line_2d_regression ()
 Constructor. More...
 
 ~vgl_line_2d_regression ()=default
 
unsigned int get_n_pts () const
 The number of points added. More...
 
void increment_partial_sums (const T x, const T y)
 Add a point to the 2d_regression. More...
 
void decrement_partial_sums (const T x, const T y)
 Remove a point from the 2d_regression. More...
 
void clear ()
 Clear 2d_regression sums. More...
 
double get_rms_error (const T a, const T b, const T c)
 Get fitting error for a given line. More...
 
double get_rms_error ()
 Get fitting error for current fitted line. More...
 
void init_rms_error_est ()
 Initialize estimated fitting error. More...
 
double get_rms_error_est (vgl_point_2d< T > const &p, bool increment=true)
 Get estimated fitting error if the point (x, y) were added to the fit. More...
 
vgl_line_2d< T > get_line () const
 Get the fitted line. More...
 
bool fit ()
 Fit a line to the current point set. More...
 
bool fit_constrained (T x, T y)
 Fit a line to the current point set constrained to pass through (x,y). More...
 

Private Attributes

unsigned int npts_
 number of points in the regression data More...
 
vgl_line_2d< T > line_
 the fitted line More...
 
Sx_
 
Sy_
 
Sxx_
 
Sxy_
 
Syy_
 partial sums More...
 
double squared_error_
 an estimate of the squared error More...
 

Detailed Description

template<class T>
class vgl_line_2d_regression< T >

A class to hold the line 2d_regression data and actual fitting code.

In addition to fitting a line to a set of points (orthogonal regression), it is designed to help with incremental fitting. You can inexpensively add and remove points. This class does not store the points; it merely stores enough aggregate information to estimate the line parameters.

Definition at line 7 of file vgl_algo_fwd.h.

Constructor & Destructor Documentation

◆ vgl_line_2d_regression()

template<class T >
vgl_line_2d_regression< T >::vgl_line_2d_regression ( )

Constructor.

Definition at line 20 of file vgl_line_2d_regression.hxx.

◆ ~vgl_line_2d_regression()

template<class T>
vgl_line_2d_regression< T >::~vgl_line_2d_regression ( )
default

Member Function Documentation

◆ clear()

template<class T >
void vgl_line_2d_regression< T >::clear ( )

Clear 2d_regression sums.

Clear the regression sums.

This will reset the object to the freshly constructed state of having zero points.

Definition at line 52 of file vgl_line_2d_regression.hxx.

◆ decrement_partial_sums()

template<class T >
void vgl_line_2d_regression< T >::decrement_partial_sums ( const T  x,
const T  y 
)

Remove a point from the 2d_regression.

Remove a point from the current regression sums.

This should be a previously added point, although this cannot be verified.

Definition at line 39 of file vgl_line_2d_regression.hxx.

◆ fit()

template<class T >
bool vgl_line_2d_regression< T >::fit ( )

Fit a line to the current point set.

Fit a line to the current regression data.

Definition at line 65 of file vgl_line_2d_regression.hxx.

◆ fit_constrained()

template<class T >
bool vgl_line_2d_regression< T >::fit_constrained ( x,
y 
)

Fit a line to the current point set constrained to pass through (x,y).

Definition at line 85 of file vgl_line_2d_regression.hxx.

◆ get_line()

template<class T>
vgl_line_2d<T> vgl_line_2d_regression< T >::get_line ( ) const
inline

Get the fitted line.

Definition at line 79 of file vgl_line_2d_regression.h.

◆ get_n_pts()

template<class T>
unsigned int vgl_line_2d_regression< T >::get_n_pts ( ) const
inline

The number of points added.

Definition at line 40 of file vgl_line_2d_regression.h.

◆ get_rms_error() [1/2]

template<class T >
double vgl_line_2d_regression< T >::get_rms_error ( const T  a,
const T  b,
const T  c 
)

Get fitting error for a given line.

Definition at line 105 of file vgl_line_2d_regression.hxx.

◆ get_rms_error() [2/2]

template<class T >
double vgl_line_2d_regression< T >::get_rms_error ( )

Get fitting error for current fitted line.

Definition at line 116 of file vgl_line_2d_regression.hxx.

◆ get_rms_error_est()

template<class T >
double vgl_line_2d_regression< T >::get_rms_error_est ( vgl_point_2d< T > const &  p,
bool  increment = true 
)

Get estimated fitting error if the point (x, y) were added to the fit.

estimate of the fitting error if a new point is added.

You must call init_rms_error_est() to initialize the running totals before the first use of this function.

If increment is true, the running totals are updated as if the point p was added to the point set. It does not update the point set, however, so the point will not affect subsequent line estimation.

Worst case is distance from the point, (x, y) to the current line. Add the error to the accumulating estimation sum.

Definition at line 143 of file vgl_line_2d_regression.hxx.

◆ increment_partial_sums()

template<class T >
void vgl_line_2d_regression< T >::increment_partial_sums ( const T  x,
const T  y 
)

Add a point to the 2d_regression.

Add a point to the current regression sums.

Definition at line 27 of file vgl_line_2d_regression.hxx.

◆ init_rms_error_est()

template<class T >
void vgl_line_2d_regression< T >::init_rms_error_est ( )

Initialize estimated fitting error.

We want to add points to the regression until it is likely that the fitting error has been exceeded.

  squared_error_  = squared_error_ + d^2
                         npts_+1

Initialize the recursive estimation of fitting error

Definition at line 132 of file vgl_line_2d_regression.hxx.

Member Data Documentation

◆ line_

template<class T>
vgl_line_2d<T> vgl_line_2d_regression< T >::line_
private

the fitted line

Definition at line 32 of file vgl_line_2d_regression.h.

◆ npts_

template<class T>
unsigned int vgl_line_2d_regression< T >::npts_
private

number of points in the regression data

Definition at line 31 of file vgl_line_2d_regression.h.

◆ squared_error_

template<class T>
double vgl_line_2d_regression< T >::squared_error_
private

an estimate of the squared error

Definition at line 34 of file vgl_line_2d_regression.h.

◆ Sx_

template<class T>
T vgl_line_2d_regression< T >::Sx_
private

Definition at line 33 of file vgl_line_2d_regression.h.

◆ Sxx_

template<class T>
T vgl_line_2d_regression< T >::Sxx_
private

Definition at line 33 of file vgl_line_2d_regression.h.

◆ Sxy_

template<class T>
T vgl_line_2d_regression< T >::Sxy_
private

Definition at line 33 of file vgl_line_2d_regression.h.

◆ Sy_

template<class T>
T vgl_line_2d_regression< T >::Sy_
private

Definition at line 33 of file vgl_line_2d_regression.h.

◆ Syy_

template<class T>
T vgl_line_2d_regression< T >::Syy_
private

partial sums

Definition at line 33 of file vgl_line_2d_regression.h.


The documentation for this class was generated from the following files: