contrib/mul/vimt/vimt_bilin_interp.h
Go to the documentation of this file.
00001 // This is mul/vimt/vimt_bilin_interp.h
00002 #ifndef vimt_bilin_interp_h_
00003 #define vimt_bilin_interp_h_
00004 //:
00005 //  \file
00006 //  \brief Bilinear interpolation functions for 2D images
00007 //  \author Tim Cootes
00008 
00009 #include <vil/vil_bilin_interp.h>
00010 #include <vimt/vimt_image_2d_of.h>
00011 #include <vgl/vgl_point_2d.h>
00012 
00013 //: Compute bilinear interpolation at (x,y) in world coordinates, no bound checks
00014 //  Interpolates given plane of image.image() at image.world2im(p)
00015 template<class T>
00016 inline double vimt_bilin_interp_safe(const vimt_image_2d_of<T>& image,
00017                                      const vgl_point_2d<double>& p,
00018                                      int plane=0)
00019 {
00020   vgl_point_2d<double> im_p = image.world2im()(p);
00021   const vil_image_view<T>& im = image.image();
00022   return vil_bilin_interp_safe(im_p.x(),im_p.y(),
00023                                im.top_left_ptr()+plane*im.planestep(),
00024                                im.ni(),im.nj(),  im.istep(),im.jstep());
00025 }
00026 
00027 #endif // vimt_bilin_interp_h_