contrib/mul/vil3d/vil3d_resample_trilinear.h
Go to the documentation of this file.
00001 // This is mul/vil3d/vil3d_resample_trilinear.h
00002 #ifndef vil3d_resample_trilinear_h_
00003 #define vil3d_resample_trilinear_h_
00004 
00005 //:
00006 // \file
00007 // \brief Resample a 3D image by a different factor in each dimension
00008 // \author Kevin de Souza, Ian Scott
00009 
00010 #include <vil3d/vil3d_image_view.h>
00011 
00012 
00013 //: Sample grid of points in one image and place in another, using trilinear interpolation.
00014 //  dest_image(i,j,k,p) is sampled from the src_image at
00015 //  (x0+i.dx1+j.dx2+k.dx3, y0+i.dy1+j.dy2+k.dy3, z0+i.dz1+j.dz2+k.dz3), 
00016 //  where i=[0..n1-1], j=[0..n2-1], k=[0..n3-1].
00017 //  dest_image resized to (n1,n2,n3,src_image.nplanes())
00018 //  Points outside image return zero or \a outval
00019 template <class S, class T>
00020 void vil3d_resample_trilinear(const vil3d_image_view<S>& src_image,
00021                               vil3d_image_view<T>& dest_image,
00022                               double x0, double y0, double z0, 
00023                               double dx1, double dy1, double dz1,
00024                               double dx2, double dy2, double dz2, 
00025                               double dx3, double dy3, double dz3, 
00026                               int n1, int n2, int n3,
00027                               T outval=0, double edge_tol=0);
00028 
00029 
00030 //: Sample grid of points in one image and place in another, using trilinear interpolation and edge extension.
00031 //  dest_image(i,j,k,p) is sampled from the src_image at
00032 //  (x0+i.dx1+j.dx2+k.dx3, y0+i.dy1+j.dy2+k.dy3, z0+i.dz1+j.dz2+k.dz3), 
00033 //  where i=[0..n1-1], j=[0..n2-1], k=[0..n3-1].
00034 //  dest_image resized to (n1,n2,n3,src_image.nplanes())
00035 //  Points outside src_image return the value of the nearest valid pixel.
00036 template <class S, class T>
00037 void vil3d_resample_trilinear_edge_extend(const vil3d_image_view<S>& src_image,
00038                                           vil3d_image_view<T>& dest_image,
00039                                           double x0, double y0, double z0, 
00040                                           double dx1, double dy1, double dz1,
00041                                           double dx2, double dy2, double dz2, 
00042                                           double dx3, double dy3, double dz3, 
00043                                           int n1, int n2, int n3);
00044 
00045 
00046 //: Resample image to a specified dimensions (n1 * n2 * n3)
00047 template <class S, class T>
00048 void vil3d_resample_trilinear(const vil3d_image_view<S>& src_image,
00049                               vil3d_image_view<T>& dest_image,
00050                               int n1, int n2, int n3);
00051 
00052 
00053 //: Resample a 3D image by a different factor in each dimension.
00054 //  \p dst_image resized by factors \p dx, \p dy, \p dz.
00055 // \note The upper image boundaries are extended.
00056 // \param dx Scaling factor >1
00057 // \param dy Scaling factor >1
00058 // \param dz Scaling factor >1
00059 //  dst_image(i, j, k, p) is sampled from src_image(i/dx, j/dy, k/dz, p).
00060 // Interpolated values are rounded when the type T is smaller than double.
00061 template <class T>
00062 void vil3d_resample_trilinear(const vil3d_image_view<T>& src_image,
00063                               vil3d_image_view<T>& dst_image,
00064                               const double dx,
00065                               const double dy,
00066                               const double dz);
00067 
00068 //: Resample a 3D image by a factor of 2 in each dimension.
00069 // \p dst_image is resized to 2*src_image.n?()-1 in each direction.
00070 // Interpolated values are truncated when the type T is smaller than double.
00071 template <class T>
00072 void vil3d_resample_trilinear_scale_2(
00073   const vil3d_image_view<T>& src_image,
00074   vil3d_image_view<T>& dst_image);
00075 
00076 #endif // vil3d_resample_trilinear_h_