1 #ifndef vil_quad_distance_function_h_ 2 #define vil_quad_distance_function_h_ 11 # include <vcl_msvc_warnings.h> 19 std::vector<double>& y,
20 std::vector<double>& z,
double a,
21 double x0,
double y0,
double n)
28 double new_z = 0.5*((y0-y[k])/a + (x0*x0-x[k]*x[k]))/(x0-x[k]);
40 x[0]=x0; y[0]=y0; z[0]=0.0;
61 std::vector<double>& x,
62 std::vector<double>& y,
63 std::vector<double>& z,
double a)
65 x.resize(1); x[0]=0.0;
66 y.resize(1); y[0]=double(*src);
67 z.resize(1); z[0]=0.0;
69 for (
unsigned int x0=1;x0<n;++x0,src+=s_step)
73 z.push_back(static_cast<double>(n));
82 const std::vector<double>& y,
83 const std::vector<double>& z,
double a,
84 destT* dest, std::ptrdiff_t d_step,
88 for (
unsigned int i=0;i<n;++i,dest+=d_step)
91 *dest = destT(y[k] + a*(i-x[k])*(i-x[k]));
103 template<
class destT,
class iT>
105 const std::vector<double>& y,
106 const std::vector<double>& z,
108 destT* dest, std::ptrdiff_t d_step,
110 iT* pos, std::ptrdiff_t p_step)
113 for (
unsigned int i=0;i<n;++i,dest+=d_step,pos+=p_step)
115 while (z[k+1]<i) ++k;
116 *dest = destT(y[k] + a*(i-x[k])*(i-x[k]));
127 template<
class srcT,
class destT>
131 destT* dest, std::ptrdiff_t d_step)
133 std::vector<double> x,y,z;
145 template<
class srcT,
class destT,
class posT>
149 destT* dest, std::ptrdiff_t d_step,
150 posT* pos, std::ptrdiff_t p_step)
152 std::vector<double> x,y,z;
161 template<
class srcT,
class destT>
163 double ai,
double aj,
167 unsigned int ni=src.
ni(),nj=src.
nj();
170 std::ptrdiff_t s_istep = src.
istep(), s_jstep = src.
jstep();
171 std::ptrdiff_t t_istep = tmp.
istep(), t_jstep = tmp.
jstep();
172 std::ptrdiff_t d_istep = dest.
istep(), d_jstep = dest.
jstep();
177 std::vector<double> x,y,z;
180 for (
unsigned int j=0;j<nj;++j, s_row+=s_jstep, t_row+=t_jstep)
188 for (
unsigned int i=0;i<ni;++i, d_col+=d_istep, t_col+=t_istep)
200 template<
class srcT,
class destT,
class posT>
202 double ai,
double aj,
207 unsigned int ni=src.
ni(), nj=src.
nj();
212 std::ptrdiff_t s_istep = src.
istep(), s_jstep = src.
jstep();
213 std::ptrdiff_t t_istep = tmp.
istep(), t_jstep = tmp.
jstep();
214 std::ptrdiff_t d_istep = dest.
istep(), d_jstep = dest.
jstep();
215 std::ptrdiff_t tp_istep = tmp_pos.
istep(), tp_jstep = tmp_pos.
jstep();
216 std::ptrdiff_t p_istep = pos.
istep(), p_jstep = pos.
jstep();
222 std::vector<double> x,y,z;
225 for (
unsigned int j=0;j<nj;++j,s_row+=s_jstep,t_row+=t_jstep,tp_row+=tp_jstep)
237 for (
unsigned int i=0;i<ni;++i, d_col+=d_istep, t_col+=t_istep,
238 pi_col+=p_istep, pj_col+=p_istep,
244 for (
unsigned int j=0;j<nj;++j)
246 pi_col[j*p_jstep] = tp_col[pj_col[j*p_jstep]*tp_jstep];
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).
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.
Concrete view of image data of type T held in memory.
void set_size(unsigned ni, unsigned nj) override
resize current planes to ni x nj.
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.
std::ptrdiff_t jstep() const
Add this to your pixel pointer to get next j pixel.
unsigned ni() const
Width.
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.
unsigned nj() const
Height.
std::ptrdiff_t planestep() const
Add this to your pixel pointer to get pixel on next plane.
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.
A base class reference-counting view of some image data.
T * top_left_ptr()
Pointer to the first (top left in plane 0) pixel.
unsigned nplanes() const
Number of planes.
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).
std::ptrdiff_t istep() const
Add this to your pixel pointer to get next i pixel.