Public Member Functions | Private Attributes
vgl_line_2d_regression< T > Class Template Reference

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

#include <vgl_line_2d_regression.h>

List of all members.

Public Member Functions

 vgl_line_2d_regression ()
 Constructor.
 ~vgl_line_2d_regression ()
unsigned int get_n_pts () const
 The number of points added.
void increment_partial_sums (const T x, const T y)
 Add a point to the 2d_regression.
void decrement_partial_sums (const T x, const T y)
 Remove a point from the 2d_regression.
void clear ()
 Clear 2d_regression sums.
double get_rms_error (const T a, const T b, const T c)
 Get fitting error for a given line.
double get_rms_error ()
 Get fitting error for current fitted line.
void init_rms_error_est ()
 Initialize estimated fitting error.
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.
vgl_line_2d< T > get_line () const
 Get the fitted line.
bool fit ()
 Fit a line to the current point set.
bool fit_constrained (T x, T y)
 Fit a line to the current point set constrained to pass through (x,y).

Private Attributes

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

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 31 of file vgl_line_2d_regression.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 17 of file vgl_line_2d_regression.txx.

template<class T>
vgl_line_2d_regression< T >::~vgl_line_2d_regression ( ) [inline]

Definition at line 40 of file vgl_line_2d_regression.h.


Member Function Documentation

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 49 of file vgl_line_2d_regression.txx.

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 36 of file vgl_line_2d_regression.txx.

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 62 of file vgl_line_2d_regression.txx.

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 82 of file vgl_line_2d_regression.txx.

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

Get the fitted line.

Definition at line 82 of file vgl_line_2d_regression.h.

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

The number of points added.

Definition at line 43 of file vgl_line_2d_regression.h.

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 102 of file vgl_line_2d_regression.txx.

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

Get fitting error for current fitted line.

Definition at line 113 of file vgl_line_2d_regression.txx.

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 140 of file vgl_line_2d_regression.txx.

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 24 of file vgl_line_2d_regression.txx.

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 129 of file vgl_line_2d_regression.txx.


Member Data Documentation

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

the fitted line

Definition at line 35 of file vgl_line_2d_regression.h.

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

number of points in the regression data

Definition at line 34 of file vgl_line_2d_regression.h.

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

an estimate of the squared error

Definition at line 37 of file vgl_line_2d_regression.h.

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

Definition at line 36 of file vgl_line_2d_regression.h.

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

Definition at line 36 of file vgl_line_2d_regression.h.

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

Definition at line 36 of file vgl_line_2d_regression.h.

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

Definition at line 36 of file vgl_line_2d_regression.h.

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

partial sums

Definition at line 36 of file vgl_line_2d_regression.h.


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