2 #ifndef vil_resample_bilin_hxx_ 3 #define vil_resample_bilin_hxx_ 25 && y0+1 <= image.
nj();
34 template <
class sType,
class dType>
37 double x0,
double y0,
double dx1,
double dy1,
38 double dx2,
double dy2,
int n1,
int n2)
44 y0+(n1-1)*dy1+(n2-1)*dy2,src_image);
47 std::cout<<
"src_image= "<<src_image<<std::endl
48 <<
"x0="<<x0<<std::endl
49 <<
"y0="<<y0<<std::endl
50 <<
"x0+(n1-1)*dx1+(n2-1)*dx2="<<x0+(n1-1)*dx1+(n2-1)*dx2<<std::endl
51 <<
"y0+(n1-1)*dy1+(n2-1)*dy2="<<y0+(n1-1)*dy1+(n2-1)*dy2<<std::endl;
54 const unsigned ni = src_image.
ni();
55 const unsigned nj = src_image.
nj();
56 const unsigned np = src_image.
nplanes();
57 const std::ptrdiff_t istep = src_image.
istep();
58 const std::ptrdiff_t jstep = src_image.
jstep();
59 const std::ptrdiff_t pstep = src_image.
planestep();
63 const std::ptrdiff_t d_istep = dest_image.
istep();
64 const std::ptrdiff_t d_jstep = dest_image.
jstep();
65 const std::ptrdiff_t d_pstep = dest_image.
planestep();
75 dType *row = d_plane0;
76 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
80 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
86 dType *row = d_plane0;
87 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
91 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
93 for (
unsigned int p=0;p<np;++p)
104 dType *row = d_plane0;
105 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
109 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
116 dType *row = d_plane0;
117 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
121 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
123 for (
unsigned int p=0;p<np;++p)
134 template <
class sType,
class dType>
142 double dx1=f*(src_image.
ni()-1)*1.0/(n1-1);
145 double dy2=f*(src_image.
nj()-1)*1.0/(n2-1);
156 template <
class sType,
class dType>
160 double x0,
double y0,
double dx1,
double dy1,
161 double dx2,
double dy2,
int n1,
int n2)
167 y0+(n1-1)*dy1+(n2-1)*dy2,src_image);
170 std::cout<<
"src_image= "<<src_image<<std::endl
171 <<
"x0="<<x0<<std::endl
172 <<
"y0="<<y0<<std::endl
173 <<
"x0+(n1-1)*dx1+(n2-1)*dx2="<<x0+(n1-1)*dx1+(n2-1)*dx2<<std::endl
174 <<
"y0+(n1-1)*dy1+(n2-1)*dy2="<<y0+(n1-1)*dy1+(n2-1)*dy2<<std::endl;
177 const unsigned ni = src_image.
ni();
178 const unsigned nj = src_image.
nj();
179 const unsigned np = src_image.
nplanes();
180 const std::ptrdiff_t istep = src_image.
istep();
181 const std::ptrdiff_t jstep = src_image.
jstep();
182 const std::ptrdiff_t pstep = src_image.
planestep();
186 const std::ptrdiff_t d_istep = dest_image.
istep();
187 const std::ptrdiff_t d_jstep = dest_image.
jstep();
188 const std::ptrdiff_t d_pstep = dest_image.
planestep();
198 dType *row = d_plane0;
199 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
203 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
209 dType *row = d_plane0;
210 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
214 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
216 for (
unsigned int p=0;p<np;++p)
227 dType *row = d_plane0;
228 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
232 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
234 x,y,plane0,ni,nj,istep,jstep);
239 dType *row = d_plane0;
240 for (
int j=0;j<n2;++j,x1+=dx2,y1+=dy2,row+=d_jstep)
244 for (
int i=0;i<n1;++i,x+=dx1,y+=dy1,dpt+=d_istep)
246 for (
unsigned int p=0;p<np;++p)
248 x,y,plane0+p*pstep,ni,nj,istep,jstep);
257 template <
class sType,
class dType>
265 double dx1=f*(src_image.
ni()-1)*1.0/(n1-1);
268 double dy2=f*(src_image.
nj()-1)*1.0/(n2-1);
270 src_image, dest_image, x0, y0, dx1, dy1, dx2, dy2, n1, n2 );
272 #define VIL_RESAMPLE_BILIN_INSTANTIATE( sType, dType ) \ 273 template void vil_resample_bilin(const vil_image_view<sType >& src_image, \ 274 vil_image_view<dType >& dest_image, \ 275 double x0, double y0, double dx1, double dy1, \ 276 double dx2, double dy2, int n1, int n2); \ 277 template void vil_resample_bilin(const vil_image_view<sType >& src_image, \ 278 vil_image_view<dType >& dest_image, \ 280 template void vil_resample_bilin_edge_extend(const vil_image_view<sType >& src_image, \ 281 vil_image_view<dType >& dest_image, \ 282 double x0, double y0, double dx1, double dy1, \ 283 double dx2, double dy2, int n1, int n2); \ 284 template void vil_resample_bilin_edge_extend(const vil_image_view<sType >& src_image, \ 285 vil_image_view<dType >& dest_image, \ 288 #endif // vil_resample_bilin_hxx_ An abstract base class of smart pointers to actual image data in memory.
Concrete view of image data of type T held in memory.
bool vil_resample_bilin_corner_in_image(double x0, double y0, const vil_image_view_base &image)
This function should not be the same in bicub and bilin.
void set_size(unsigned ni, unsigned nj) override
resize current planes to ni x nj.
double vil_bilin_interp_safe(const vil_image_view< T > &view, double x, double y, unsigned p=0)
Compute bilinear interpolation at (x,y), with bound checks.
Sample grid of points with bilinear interpolation in one image and place in another.
std::ptrdiff_t jstep() const
Add this to your pixel pointer to get next j pixel.
unsigned ni() const
Width.
unsigned nj() const
Height.
std::ptrdiff_t planestep() const
Add this to your pixel pointer to get pixel on next plane.
double vil_bilin_interp_safe_extend(const vil_image_view< T > &view, double x, double y, unsigned p=0)
Compute bilinear interpolation at (x,y), with bound checks.
T * top_left_ptr()
Pointer to the first (top left in plane 0) pixel.
unsigned nplanes() const
Number of planes.
double vil_bilin_interp_raw(double x, double y, const T *data, std::ptrdiff_t xstep, std::ptrdiff_t ystep)
Compute bilinear interpolation at (x,y), no bound checks.
void vil_resample_bilin(const vil_image_view< sType > &src_image, vil_image_view< dType > &dest_image, double x0, double y0, double dx1, double dy1, double dx2, double dy2, int n1, int n2)
Sample grid of points in one image and place in another, using bilinear interpolation.
std::ptrdiff_t istep() const
Add this to your pixel pointer to get next i pixel.
void vil_resample_bilin_edge_extend(const vil_image_view< sType > &src_image, vil_image_view< dType > &dest_image, double x0, double y0, double dx1, double dy1, double dx2, double dy2, int n1, int n2)
Sample grid of points in one image and place in another, using bilinear interpolation.
Bilinear interpolation functions for 2D images.