Functions
core/vil/algo/vil_quad_distance_function.h File Reference

Functions to compute quadratic distance functions. More...

#include <vil/vil_image_view.h>
#include <vcl_vector.h>
#include <vcl_cassert.h>

Go to the source code of this file.

Functions

void vil_update_parabola_set (vcl_vector< double > &x, vcl_vector< double > &y, vcl_vector< double > &z, double a, double x0, double y0, double n)
 Add parabola y=y0+(x-x0)^2 to lower envelope defined by (x,y,z).
template<class srcT >
void vil_quad_envelope (const srcT *src, vcl_ptrdiff_t s_step, unsigned int n, vcl_vector< double > &x, vcl_vector< double > &y, vcl_vector< double > &z, double a)
 Compute parabolas forming lower envelope from set over range [0,n).
template<class destT >
void vil_sample_quad_envelope (const vcl_vector< double > &x, const vcl_vector< double > &y, const vcl_vector< double > &z, double a, destT *dest, vcl_ptrdiff_t d_step, unsigned int n)
 Sample from lower envelope of a set of parabolas.
template<class destT , class iT >
void vil_sample_quad_envelope_with_pos (const vcl_vector< double > &x, const vcl_vector< double > &y, const vcl_vector< double > &z, double a, destT *dest, vcl_ptrdiff_t d_step, unsigned int n, iT *pos, vcl_ptrdiff_t p_step)
 Sample from lower envelope of a set of parabolas.
template<class srcT , class destT >
void vil_quad_distance_function_1D (const srcT *src, vcl_ptrdiff_t s_step, unsigned int n, double a, destT *dest, vcl_ptrdiff_t d_step)
 Compute quadratic distance function for a 1D function.
template<class srcT , class destT , class posT >
void vil_quad_distance_function_1D (const srcT *src, vcl_ptrdiff_t s_step, unsigned int n, double a, destT *dest, vcl_ptrdiff_t d_step, posT *pos, vcl_ptrdiff_t p_step)
 Compute quadratic distance function for a 1D function.
template<class srcT , class destT >
void vil_quad_distance_function (const vil_image_view< srcT > &src, double ai, double aj, vil_image_view< destT > &dest)
 Apply quadratic distance transform along each row of src.
template<class srcT , class destT , class posT >
void vil_quad_distance_function (const vil_image_view< srcT > &src, double ai, double aj, vil_image_view< destT > &dest, vil_image_view< posT > &pos)
 Apply quadratic distance transform along each row of src.

Detailed Description

Functions to compute quadratic distance functions.

Author:
Tim Cootes

Definition in file vil_quad_distance_function.h.


Function Documentation

template<class srcT , class destT >
void vil_quad_distance_function ( const vil_image_view< srcT > &  src,
double  ai,
double  aj,
vil_image_view< destT > &  dest 
) [inline]

Apply quadratic distance transform along each row of src.

$ dest(x,y)=min_i,j (src(x+i,y+j)+ai(i^2)+aj(j^2)) $

Definition at line 159 of file vil_quad_distance_function.h.

template<class srcT , class destT , class posT >
void vil_quad_distance_function ( const vil_image_view< srcT > &  src,
double  ai,
double  aj,
vil_image_view< destT > &  dest,
vil_image_view< posT > &  pos 
) [inline]

Apply quadratic distance transform along each row of src.

$ dest(x,y)=min_i,j (src(x+i,y+j)+ai(i^2)+aj(j^2)) $ (pos(x,y,0),pos(x,y,1)) gives the position (x+i,y+j) leading to minima

Definition at line 198 of file vil_quad_distance_function.h.

template<class srcT , class destT >
void vil_quad_distance_function_1D ( const srcT *  src,
vcl_ptrdiff_t  s_step,
unsigned int  n,
double  a,
destT *  dest,
vcl_ptrdiff_t  d_step 
) [inline]

Compute quadratic distance function for a 1D function.

On exit dest(x) = min_i src(x+i)+a(i^2) Implementation of Felzenszwalb and Huttenlocher's algorithm, as described in "Distance Transforms of Sampled Functions".

dest(x) = dest[x*d_step], src(x)=src[x*s_step]

Definition at line 125 of file vil_quad_distance_function.h.

template<class srcT , class destT , class posT >
void vil_quad_distance_function_1D ( const srcT *  src,
vcl_ptrdiff_t  s_step,
unsigned int  n,
double  a,
destT *  dest,
vcl_ptrdiff_t  d_step,
posT *  pos,
vcl_ptrdiff_t  p_step 
) [inline]

Compute quadratic distance function for a 1D function.

On exit dest(x) = min_i src(x+i)+a(i^2), pos(x) gives position (x+i) which leads to the minima Implementation of Felzenszwalb and Huttenlocher's algorithm, as described in "Distance Transforms of Sampled Functions".

dest(x) = dest[x*d_step], src(x)=src[x*s_step], pos(x)=pos[x*p_step]

Definition at line 143 of file vil_quad_distance_function.h.

template<class srcT >
void vil_quad_envelope ( const srcT *  src,
vcl_ptrdiff_t  s_step,
unsigned int  n,
vcl_vector< double > &  x,
vcl_vector< double > &  y,
vcl_vector< double > &  z,
double  a 
) [inline]

Compute parabolas forming lower envelope from set over range [0,n).

Set of parabolas y=src[i*s_step]+a(x-i)^2 i=0..n-1 Select those defining lower envelope in range [0,n) On exit, selected parabolas are y' = y[i]+(x'-x[i])^2 Parabola i defines the envelope in the range (z[i],z[i+1]). Thus z.size()==x.size()+1

Definition at line 56 of file vil_quad_distance_function.h.

template<class destT >
void vil_sample_quad_envelope ( const vcl_vector< double > &  x,
const vcl_vector< double > &  y,
const vcl_vector< double > &  z,
double  a,
destT *  dest,
vcl_ptrdiff_t  d_step,
unsigned int  n 
) [inline]

Sample from lower envelope of a set of parabolas.

Parabolas are y' = y[i]+a(x'-x[i])^2 Parabola i defines the envelope in the range (z[i],z[i+1]). Thus z.size()==x.size()+1

Definition at line 78 of file vil_quad_distance_function.h.

template<class destT , class iT >
void vil_sample_quad_envelope_with_pos ( const vcl_vector< double > &  x,
const vcl_vector< double > &  y,
const vcl_vector< double > &  z,
double  a,
destT *  dest,
vcl_ptrdiff_t  d_step,
unsigned int  n,
iT *  pos,
vcl_ptrdiff_t  p_step 
) [inline]

Sample from lower envelope of a set of parabolas.

Parabolas are y' = y[i]+a(x'-x[i])^2 Parabola i defines the envelope in the range (z[i],z[i+1]). Thus z.size()==x.size()+1

iT assumed to be an integer type (vxl_byte,short, int etc) On exit, pos[i*p_step] gives the x position of the parabola used to compute the envelope at position i.

Definition at line 101 of file vil_quad_distance_function.h.

void vil_update_parabola_set ( vcl_vector< double > &  x,
vcl_vector< double > &  y,
vcl_vector< double > &  z,
double  a,
double  x0,
double  y0,
double  n 
) [inline]

Add parabola y=y0+(x-x0)^2 to lower envelope defined by (x,y,z).

Parabolas are y' = y[i]+a(x'-x[i])^2 Parabola i defines the envelope in the range (z[i],z[i+1]).

Definition at line 15 of file vil_quad_distance_function.h.