2 #ifndef vil_nearest_interp_h_ 3 #define vil_nearest_interp_h_ 18 # include <vcl_msvc_warnings.h> 28 std::ptrdiff_t xstep, std::ptrdiff_t ystep)
30 int ix = int(x + 0.5);
31 int iy = int(y + 0.5);
32 return *(data + ix*xstep + iy*ystep);
51 std::ptrdiff_t xstep, std::ptrdiff_t ystep)
53 int ix = int(x + 0.5);
54 int iy = int(y + 0.5);
55 if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
56 return *(data + ix*xstep + iy*ystep);
83 std::ptrdiff_t xstep, std::ptrdiff_t ystep)
85 int ix = int(x + 0.5);
86 int iy = int(y + 0.5);
91 return *(data + ix*xstep + iy*ystep);
116 std::ptrdiff_t xstep, std::ptrdiff_t ystep)
118 int ix = int(x + 0.5);
119 int iy = int(y + 0.5);
130 return *(data + ix*xstep + iy*ystep);
142 int ix = int(x + 0.5);
143 int iy = int(y + 0.5);
147 if (ix>=(
int)view.
ni()) ix=view.
ni()-1;
152 if (iy>=(
int)view.
nj()) iy=view.
nj()-1;
154 return view(ix, iy, p);
157 #endif // vil_nearest_interp_h_ Concrete view of image data of type T held in memory.
T vil_nearest_interp_unsafe(const vil_image_view< T > &view, double x, double y, unsigned p=0)
Compute nearest neighbour interpolation at (x,y), no bound checks. Requires -0.5<=x<ni-0....
std::ptrdiff_t jstep() const
Add this to your pixel pointer to get next j pixel.
unsigned ni() const
Width.
unsigned nj() const
Height.
T vil_nearest_interp_safe_extend(const vil_image_view< T > &view, double x, double y, unsigned p=0)
Compute nearest neighbour interpolation at (x,y), with bound checks.
T vil_nearest_interp(const vil_image_view< T > &view, double x, double y, unsigned p=0)
Compute nearest neighbour interpolation at (x,y), with minimal bound checks.
T vil_nearest_interp_safe(const vil_image_view< T > &view, double x, double y, unsigned p=0)
Compute nearest neighbour interpolation at (x,y), with bound checks.
std::ptrdiff_t istep() const
Add this to your pixel pointer to get next i pixel.