Go to the documentation of this file.00001
00002 #ifndef vil3d_resample_simple_txx_
00003 #define vil3d_resample_simple_txx_
00004
00005
00006
00007
00008
00009 #include "vil3d_resample_simple.h"
00010
00011
00012
00013
00014
00015 template <class T >
00016 void vil3d_resample_simple(const vil3d_image_view< T >& src_image,
00017 vil3d_image_view< T >& dst_image,
00018 const double dx,
00019 const double dy,
00020 const double dz)
00021 {
00022
00023 const unsigned np = src_image.nplanes();
00024
00025 const unsigned sni = src_image.ni();
00026 const unsigned snj = src_image.nj();
00027 const unsigned snk = src_image.nk();
00028
00029 const unsigned dni = static_cast<unsigned>(sni*dx);
00030 const unsigned dnj = static_cast<unsigned>(snj*dy);
00031 const unsigned dnk = static_cast<unsigned>(snk*dz);
00032
00033 dst_image.set_size(dni, dnj, dnk, np);
00034 const vcl_ptrdiff_t d_istep = dst_image.istep();
00035 const vcl_ptrdiff_t d_jstep = dst_image.jstep();
00036 const vcl_ptrdiff_t d_kstep = dst_image.kstep();
00037 const vcl_ptrdiff_t d_pstep = dst_image.planestep();
00038 T* d_plane = dst_image.origin_ptr();
00039
00040
00041
00042 for (unsigned p=0; p<np; ++p, d_plane+=d_pstep)
00043 {
00044 T* d_slice = d_plane;
00045 for (unsigned k=0; k<dnk; ++k, d_slice+=d_kstep)
00046 {
00047 T* d_row = d_slice;
00048 for (unsigned j=0; j<dnj; ++j, d_row+=d_jstep)
00049 {
00050 T* d_pix = d_row;
00051 for (unsigned i=0; i<dni; ++i, d_pix+=d_istep)
00052 {
00053 *d_pix = src_image(static_cast<unsigned>(i/dx),
00054 static_cast<unsigned>(j/dy),
00055 static_cast<unsigned>(k/dz),
00056 p);
00057 }
00058 }
00059 }
00060 }
00061 }
00062
00063
00064 #define VIL3D_RESAMPLE_SIMPLE_INSTANTIATE( T ) \
00065 template void vil3d_resample_simple(const vil3d_image_view< T >& src_image, \
00066 vil3d_image_view< T >& dst_image, \
00067 const double dx, \
00068 const double dy, \
00069 const double dz)
00070
00071
00072 #endif // vil3d_resample_simple_txx_