Kernel Density objective function. More...
#include <rrel_kernel_density_obj.h>
Public Types | |
typedef vcl_vector< double > ::const_iterator | vect_const_iter |
The iterators used to pass in values. | |
typedef vcl_vector< double > ::iterator | vect_iter |
The iterators used to pass out values. | |
Public Member Functions | |
rrel_kernel_density_obj (rrel_kernel_scale_type scale_type=RREL_KERNEL_MAD) | |
Constructor. | |
virtual | ~rrel_kernel_density_obj () |
Destructor. | |
virtual double | fcn (vect_const_iter res_begin, vect_const_iter res_end, vect_const_iter scale_begin, vnl_vector< double > *param_vector=0) const |
Evaluate the objective function on heteroscedastic residuals. | |
virtual double | fcn (vect_const_iter res_begin, vect_const_iter res_end, double prior_scale=0, vnl_vector< double > *=0) const |
Evaluate the objective function on homoscedastic residuals. | |
virtual void | set_scale_type (rrel_kernel_scale_type t=RREL_KERNEL_MAD) |
Set the type of the scale. | |
virtual bool | requires_prior_scale () const |
Depends on the scale type used. | |
void | fix_x () |
x is set to 0;. | |
double | best_x (vect_const_iter res_begin, vect_const_iter res_end, double scale=0) const |
The mode of the density estimate which maximizes the estimated kernel density. | |
virtual bool | can_estimate_scale () const |
True if the objective function can estimate scale. | |
virtual double | scale (vect_const_iter, vect_const_iter) const |
Scale estimate. | |
Private Member Functions | |
double | bandwidth (vect_const_iter res_begin, vect_const_iter res_end, double prior_scale) const |
Calculate the bandwidth. | |
double | kernel_density (vect_const_iter res_begin, vect_const_iter res_end, double x, double h) const |
Given a kernel and the bandwidth, the estimated density of residuals. | |
double | kernel_function (double u) const |
Kernel function K(u). | |
Private Attributes | |
rrel_kernel_scale_type | scale_type_ |
bool | fix_x_ |
Kernel Density objective function.
Implements the Kernel Density Estimation as presented in the paper "Robust Computer Vision through Kernel Density" by Chen and Meer, 2002. Given residuals ri, i = 1,...,n, the cost function is the estimated density f(x) based on a kernel function K(u) and a bandwidth h as f(x) = -1 / (nh) * sum( K(u) ) where u = (ri-x)/h K(u) = 1.09375 * (1 - u^2)^3 h = [243 * R(K) / 35 / Mu(K)^2 / n]^0.2 * scale The scale can be provided as a prior scale, or computed by MAD or MUSE.
Definition at line 27 of file rrel_kernel_density_obj.h.
typedef vcl_vector<double>::const_iterator rrel_objective::vect_const_iter [inherited] |
The iterators used to pass in values.
Since we don't allow member templates, we have to fix on a particular type of container for residuals. Using this typedef will allow things to easily change when member templates are allowed.
Definition at line 27 of file rrel_objective.h.
typedef vcl_vector<double>::iterator rrel_objective::vect_iter [inherited] |
The iterators used to pass out values.
Definition at line 30 of file rrel_objective.h.
rrel_kernel_density_obj::rrel_kernel_density_obj | ( | rrel_kernel_scale_type | scale_type = RREL_KERNEL_MAD | ) |
Constructor.
Definition at line 25 of file rrel_kernel_density_obj.cxx.
virtual rrel_kernel_density_obj::~rrel_kernel_density_obj | ( | ) | [inline, virtual] |
Destructor.
Definition at line 34 of file rrel_kernel_density_obj.h.
double rrel_kernel_density_obj::bandwidth | ( | vect_const_iter | res_begin, |
vect_const_iter | res_end, | ||
double | prior_scale | ||
) | const [private] |
Calculate the bandwidth.
Definition at line 117 of file rrel_kernel_density_obj.cxx.
double rrel_kernel_density_obj::best_x | ( | vect_const_iter | res_begin, |
vect_const_iter | res_end, | ||
double | scale = 0 |
||
) | const |
The mode of the density estimate which maximizes the estimated kernel density.
The value can be used to shift the estimated parameters.
Definition at line 54 of file rrel_kernel_density_obj.cxx.
virtual bool rrel_objective::can_estimate_scale | ( | ) | const [inline, virtual, inherited] |
True if the objective function can estimate scale.
Some objective functions, such as MUSE, can provide an accurate inlier scale estimate.
Reimplemented in rrel_muset_obj, and rrel_lms_obj.
Definition at line 72 of file rrel_objective.h.
double rrel_kernel_density_obj::fcn | ( | vect_const_iter | res_begin, |
vect_const_iter | res_end, | ||
vect_const_iter | scale_begin, | ||
vnl_vector< double > * | param_vector = 0 |
||
) | const [virtual] |
Evaluate the objective function on heteroscedastic residuals.
Not implemented.
Implements rrel_objective.
Definition at line 32 of file rrel_kernel_density_obj.cxx.
double rrel_kernel_density_obj::fcn | ( | vect_const_iter | res_begin, |
vect_const_iter | res_end, | ||
double | prior_scale = 0 , |
||
vnl_vector< double > * | = 0 |
||
) | const [virtual] |
Evaluate the objective function on homoscedastic residuals.
prior_scale is needed if the type RREL_KERNEL_PRIOR is used.
Implements rrel_objective.
Definition at line 41 of file rrel_kernel_density_obj.cxx.
void rrel_kernel_density_obj::fix_x | ( | ) | [inline] |
x is set to 0;.
Definition at line 63 of file rrel_kernel_density_obj.h.
double rrel_kernel_density_obj::kernel_density | ( | vect_const_iter | res_begin, |
vect_const_iter | res_end, | ||
double | x, | ||
double | h | ||
) | const [private] |
Given a kernel and the bandwidth, the estimated density of residuals.
Definition at line 169 of file rrel_kernel_density_obj.cxx.
double rrel_kernel_density_obj::kernel_function | ( | double | u | ) | const [private] |
Kernel function K(u).
Definition at line 184 of file rrel_kernel_density_obj.cxx.
virtual bool rrel_kernel_density_obj::requires_prior_scale | ( | ) | const [inline, virtual] |
Depends on the scale type used.
Implements rrel_objective.
Definition at line 59 of file rrel_kernel_density_obj.h.
virtual double rrel_objective::scale | ( | vect_const_iter | , |
vect_const_iter | |||
) | const [inline, virtual, inherited] |
Scale estimate.
The result is undefined if can_estimate_scale() is false.
Reimplemented in rrel_muset_obj, and rrel_lms_obj.
Definition at line 76 of file rrel_objective.h.
virtual void rrel_kernel_density_obj::set_scale_type | ( | rrel_kernel_scale_type | t = RREL_KERNEL_MAD | ) | [inline, virtual] |
Set the type of the scale.
RREL_KERNEL_MAD uses median absolute deviations to estimate the scale. RREL_KERNEL_PRIOR uses the prior scale provided. RREL_KERNEL_MUSE uses MUSE to estimate the scale.
Definition at line 54 of file rrel_kernel_density_obj.h.
bool rrel_kernel_density_obj::fix_x_ [private] |
Definition at line 84 of file rrel_kernel_density_obj.h.
Definition at line 82 of file rrel_kernel_density_obj.h.