00001
00002 #ifndef vil_bicub_interp_h_
00003 #define vil_bicub_interp_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <vcl_cassert.h>
00015 #include <vcl_cstddef.h>
00016 #include <vil/vil_image_view.h>
00017
00018
00019
00020
00021 template<class T>
00022 double vil_bicub_interp_unsafe(double x, double y, const T* data,
00023 vcl_ptrdiff_t xstep, vcl_ptrdiff_t ystep);
00024
00025
00026
00027
00028
00029
00030 template<class T>
00031 inline double vil_bicub_interp_unsafe(double x, double y, const T* data,
00032 int , int ,
00033 vcl_ptrdiff_t xstep, vcl_ptrdiff_t ystep)
00034 {
00035 return vil_bicub_interp_unsafe(x, y, data, xstep, ystep);
00036 }
00037
00038
00039
00040
00041
00042
00043 template<class T>
00044 double vil_bicub_interp_raw(double x, double y, const T* data,
00045 vcl_ptrdiff_t xstep, vcl_ptrdiff_t ystep);
00046
00047
00048
00049
00050
00051
00052
00053 template<class T>
00054 inline double vil_bicub_interp_raw(double x, double y, const T* data,
00055 int , int ,
00056 vcl_ptrdiff_t xstep, vcl_ptrdiff_t ystep)
00057 {
00058 return vil_bicub_interp_raw(x, y, data, xstep, ystep);
00059 }
00060
00061
00062
00063
00064
00065 template<class T>
00066 inline double vil_bicub_interp_safe(double x, double y, const T* data,
00067 int nx, int ny,
00068 vcl_ptrdiff_t xstep, vcl_ptrdiff_t ystep)
00069 {
00070 if (x<1) return 0.0;
00071 if (y<1) return 0.0;
00072 if (x>nx-2) return 0.0;
00073 if (y>ny-2) return 0.0;
00074 return vil_bicub_interp_raw(x,y,data,xstep,ystep);
00075 }
00076
00077
00078
00079
00080
00081 template<class T>
00082 inline double vil_bicub_interp_safe(const vil_image_view<T> &view,
00083 double x, double y, unsigned p=0)
00084 {
00085 return vil_bicub_interp_safe(x, y, &view(0,0,p),
00086 view.ni(), view.nj(),
00087 view.istep(), view.jstep());
00088 }
00089
00090
00091
00092
00093
00094
00095 template<class T>
00096 inline double vil_bicub_interp(double x, double y, const T* data,
00097 int nx, int ny,
00098 vcl_ptrdiff_t xstep, vcl_ptrdiff_t ystep)
00099 {
00100 assert (x>=1);
00101 assert (y>=1);
00102 assert (x<=nx-2);
00103 assert (y<=ny-2);
00104 return vil_bicub_interp_raw(x,y,data,xstep,ystep);
00105 }
00106
00107
00108
00109
00110
00111
00112 template<class T>
00113 inline double vil_bicub_interp(const vil_image_view<T> &view,
00114 double x, double y, unsigned p=0)
00115 {
00116 return vil_bicub_interp(x, y, &view(0,0,p),
00117 view.ni(), view.nj(),
00118 view.istep(), view.jstep());
00119 }
00120
00121
00122
00123
00124
00125 template<class T>
00126 inline double vil_bicub_interp_safe_extend(double x, double y, const T* data,
00127 int nx, int ny,
00128 vcl_ptrdiff_t xstep, vcl_ptrdiff_t ystep)
00129 {
00130 if (x<1) x= 0.0;
00131 if (y<1) y= 0.0;
00132 if (x>nx-2) x=nx-1.0;
00133 if (y>ny-2) y=ny-1.0;
00134 return vil_bicub_interp_raw(x,y,data,xstep,ystep);
00135 }
00136
00137
00138
00139
00140
00141 template<class T>
00142 inline double vil_bicub_interp_safe_extend(const vil_image_view<T> &view,
00143 double x, double y, unsigned p=0)
00144 {
00145 return vil_bicub_interp_safe_extend(x, y, &view(0,0,p),
00146 view.ni(), view.nj(),
00147 view.istep(), view.jstep());
00148 }
00149
00150 #endif // vil_bicub_interp_h_