2 #ifndef vil_bicub_interp_hxx_ 3 #define vil_bicub_interp_hxx_ 19 # include <vcl_msvc_warnings.h> 31 std::ptrdiff_t xstep, std::ptrdiff_t ystep)
38 const T* pix1 = data + p1y*ystep + p1x*xstep;
42 double s0 = ((2-normx)*normx-1)*normx;
43 double s1 = (3*normx-5)*normx*normx+2;
44 double s2 = ((4-3*normx)*normx+1)*normx;
45 double s3 = (normx-1)*normx*normx;
47 double t0 = ((2-normy)*normy-1)*normy;
48 double t1 = (3*normy-5)*normy*normy+2;
49 double t2 = ((4-3*normy)*normy+1)*normy;
50 double t3 = (normy-1)*normy*normy;
52 #define vil_I(dx,dy) (pix1[(dx)*xstep+(dy)*ystep]) 61 double val = 0.25 * ( xi0*t0 + xi1*t1 + xi2*t2 + xi3*t3 );
68 std::ptrdiff_t xstep, std::ptrdiff_t ystep)
75 const T* pix1 = data + p1y*ystep + p1x*xstep;
81 if (normx == 0.0 && normy == 0.0)
return pix1[0];
84 double s0=-1.0, s1=-1.0, s2=-1.0, s3=-1.0;
85 double t0=-1.0, t1=-1.0, t2=-1.0, t3=-1.0;
88 s0 = ((2-normx)*normx-1)*normx;
89 s1 = (3*normx-5)*normx*normx+2;
90 s2 = ((4-3*normx)*normx+1)*normx;
91 s3 = (normx-1)*normx*normx;
95 t0 = ((2-normy)*normy-1)*normy;
96 t1 = (3*normy-5)*normy*normy+2;
97 t2 = ((4-3*normy)*normy+1)*normy;
98 t3 = (normy-1)*normy*normy;
101 #define vil_I(dx,dy) (pix1[(dx)*xstep+(dy)*ystep]) 105 val += s0*
vil_I(-1,+0);
106 val += s1*
vil_I(+0,+0);
107 val += s2*
vil_I(+1,+0);
109 val += s3*
vil_I(+2,+0);
130 double val = 0.25 * ( xi0*t0 + xi1*t1 + xi2*t2 + xi3*t3 );
135 #define VIL_BICUB_INTERP_INSTANTIATE(T) \ 137 vil_bicub_interp_unsafe (double x, double y, const T* data, \ 138 std::ptrdiff_t xstep, std::ptrdiff_t ystep); \ 140 vil_bicub_interp_raw (double x, double y, const T* data, \ 141 std::ptrdiff_t xstep, std::ptrdiff_t ystep) 143 #endif // vil_bicub_interp_hxx_ double vil_bicub_interp_raw(double x, double y, const T *data, std::ptrdiff_t xstep, std::ptrdiff_t ystep)
Compute bicubic interpolation at (x,y), no bound checks.
Bicubic interpolation functions for 2D images.
double vil_bicub_interp_unsafe(double x, double y, const T *data, std::ptrdiff_t xstep, std::ptrdiff_t ystep)
Compute bicubic interpolation at (x,y), no bound checks. Requires 1<x<ni-3, 1<y<nj-3.