Functions
vil_quad_distance_function.h File Reference

Functions to compute quadratic distance functions. More...

#include <vector>
#include <vil/vil_image_view.h>
#include <cassert>

Go to the source code of this file.

Functions

void vil_update_parabola_set (std::vector< double > &x, std::vector< double > &y, std::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). More...
 
template<class srcT >
void vil_quad_envelope (const srcT *src, std::ptrdiff_t s_step, size_t n, std::vector< double > &x, std::vector< double > &y, std::vector< double > &z, double a)
 Compute parabolas forming lower envelope from set over range [0,n). More...
 
template<class destT >
void vil_sample_quad_envelope (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, double a, destT *dest, std::ptrdiff_t d_step, size_t n)
 Sample from lower envelope of a set of parabolas. More...
 
template<class destT , class iT >
void vil_sample_quad_envelope_with_pos (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, double a, destT *dest, std::ptrdiff_t d_step, size_t n, iT *pos, std::ptrdiff_t p_step)
 Sample from lower envelope of a set of parabolas. More...
 
template<class srcT , class destT >
void vil_quad_distance_function_1D (const srcT *src, std::ptrdiff_t s_step, size_t n, double a, destT *dest, std::ptrdiff_t d_step)
 Compute quadratic distance function for a 1D function. More...
 
template<class srcT , class destT , class posT >
void vil_quad_distance_function_1D (const srcT *src, std::ptrdiff_t s_step, unsigned int n, double a, destT *dest, std::ptrdiff_t d_step, posT *pos, std::ptrdiff_t p_step)
 Compute quadratic distance function for a 1D function. More...
 
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. More...
 
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. More...
 

Detailed Description

Functions to compute quadratic distance functions.

Author
Tim Cootes

Definition in file vil_quad_distance_function.h.

Function Documentation

◆ vil_quad_distance_function() [1/2]

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 162 of file vil_quad_distance_function.h.

◆ vil_quad_distance_function() [2/2]

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 201 of file vil_quad_distance_function.h.

◆ vil_quad_distance_function_1D() [1/2]

template<class srcT , class destT >
void vil_quad_distance_function_1D ( const srcT *  src,
std::ptrdiff_t  s_step,
size_t  n,
double  a,
destT *  dest,
std::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 128 of file vil_quad_distance_function.h.

◆ vil_quad_distance_function_1D() [2/2]

template<class srcT , class destT , class posT >
void vil_quad_distance_function_1D ( const srcT *  src,
std::ptrdiff_t  s_step,
unsigned int  n,
double  a,
destT *  dest,
std::ptrdiff_t  d_step,
posT *  pos,
std::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 146 of file vil_quad_distance_function.h.

◆ vil_quad_envelope()

template<class srcT >
void vil_quad_envelope ( const srcT *  src,
std::ptrdiff_t  s_step,
size_t  n,
std::vector< double > &  x,
std::vector< double > &  y,
std::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 59 of file vil_quad_distance_function.h.

◆ vil_sample_quad_envelope()

template<class destT >
void vil_sample_quad_envelope ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  z,
double  a,
destT *  dest,
std::ptrdiff_t  d_step,
size_t  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 81 of file vil_quad_distance_function.h.

◆ vil_sample_quad_envelope_with_pos()

template<class destT , class iT >
void vil_sample_quad_envelope_with_pos ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  z,
double  a,
destT *  dest,
std::ptrdiff_t  d_step,
size_t  n,
iT *  pos,
std::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 104 of file vil_quad_distance_function.h.

◆ vil_update_parabola_set()

void vil_update_parabola_set ( std::vector< double > &  x,
std::vector< double > &  y,
std::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 18 of file vil_quad_distance_function.h.