00001
00002 #ifndef vimt3d_resample_tricubic_h_
00003 #define vimt3d_resample_tricubic_h_
00004
00005
00006
00007
00008
00009 #include <vgl/vgl_point_3d.h>
00010 #include <vgl/vgl_vector_3d.h>
00011 #include <vil3d/vil3d_image_view.h>
00012 #include <vil3d/algo/vil3d_gauss_reduce.h>
00013 #include <vil3d/vil3d_resample_tricubic.h>
00014 #include <vimt3d/vimt3d_image_3d_of.h>
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 template <class sType, class dType>
00026 inline void vimt3d_resample_tricubic(
00027 const vimt3d_image_3d_of<sType>& src_image,
00028 vimt3d_image_3d_of<dType>& dest_image,
00029 const vgl_point_3d<double>& p,
00030 const vgl_vector_3d<double>& u,
00031 const vgl_vector_3d<double>& v,
00032 const vgl_vector_3d<double>& w,
00033 int n1, int n2, int n3,
00034 dType outval=0)
00035 {
00036 const vimt3d_transform_3d& s_w2i = src_image.world2im();
00037 vgl_point_3d<double> im_p = s_w2i(p);
00038 vgl_vector_3d<double> im_u = s_w2i.delta(p, u);
00039 vgl_vector_3d<double> im_v = s_w2i.delta(p, v);
00040 vgl_vector_3d<double> im_w = s_w2i.delta(p, w);
00041
00042 vil3d_resample_tricubic(src_image.image(),dest_image.image(),
00043 im_p.x(), im_p.y(), im_p.z(),
00044 im_u.x(), im_u.y(), im_u.z(),
00045 im_v.x(), im_v.y(), im_v.z(),
00046 im_w.x(), im_w.y(), im_w.z(),
00047 n1, n2, n3,
00048 outval);
00049
00050
00051
00052 vimt3d_transform_3d d_i2w;
00053 d_i2w.set_affine(p,u,v,w);
00054 d_i2w.simplify();
00055 dest_image.set_world2im(d_i2w.inverse());
00056 }
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 template <class sType, class dType>
00070 inline void vimt3d_resample_tricubic_edge_extend(
00071 const vimt3d_image_3d_of<sType>& src_image,
00072 vimt3d_image_3d_of<dType>& dest_image,
00073 const vgl_point_3d<double>& p,
00074 const vgl_vector_3d<double>& u,
00075 const vgl_vector_3d<double>& v,
00076 const vgl_vector_3d<double>& w,
00077 int ni, int nj, int nk)
00078 {
00079 const vimt3d_transform_3d& s_w2i = src_image.world2im();
00080 vgl_point_3d<double> im_p = s_w2i(p);
00081 vgl_vector_3d<double> im_u = s_w2i.delta(p, u);
00082 vgl_vector_3d<double> im_v = s_w2i.delta(p, v);
00083 vgl_vector_3d<double> im_w = s_w2i.delta(p, w);
00084
00085 vil3d_resample_tricubic_edge_extend(src_image.image(),dest_image.image(),
00086 im_p.x(),im_p.y(),im_p.z(), im_u.x(),im_u.y(),im_u.z(),
00087 im_v.x(),im_v.y(),im_v.z(), im_w.x(),im_w.y(),im_w.z(), ni,nj,nk);
00088
00089
00090
00091 vimt3d_transform_3d d_i2w;
00092 d_i2w.set_affine(p,u,v,w);
00093 d_i2w.simplify();
00094 dest_image.set_world2im(d_i2w.inverse());
00095 }
00096
00097
00098 #endif // vimt3d_resample_tricubic_h_