Go to the documentation of this file.00001
00002 #ifndef vimt3d_sample_transformed_blob_h_
00003 #define vimt3d_sample_transformed_blob_h_
00004
00005
00006
00007
00008
00009 #include <vil3d/vil3d_image_view.h>
00010 #include <vil3d/vil3d_chord.h>
00011 #include <vimt3d/vimt3d_transform_3d.h>
00012 #include <vil3d/vil3d_trilin_interp.h>
00013 #include <vnl/vnl_vector.h>
00014
00015
00016
00017
00018
00019
00020
00021
00022 template<class T>
00023 inline void vimt3d_sample_transformed_blob(
00024 const vil3d_image_view<T>& image,
00025 const vimt3d_transform_3d& i2i,
00026 const vcl_vector<vil3d_chord>& chords,
00027 vnl_vector<double>& sample)
00028 {
00029 double *s = sample.data_block();
00030
00031 vcl_vector<vil3d_chord>::const_iterator c = chords.begin();
00032 vgl_vector_3d<double> dp = i2i(1,0,0)-i2i.origin();
00033
00034 vcl_ptrdiff_t istep = image.istep();
00035 vcl_ptrdiff_t jstep = image.jstep();
00036 vcl_ptrdiff_t kstep = image.kstep();
00037 const T* im_data = image.origin_ptr();
00038
00039 for (;c!=chords.end();++c)
00040 {
00041
00042 vgl_point_3d<double> p=i2i(c->start_x(),c->y(),c->z());
00043 double *s_end = s+c->length();
00044 for (;s!=s_end;++s,p+=dp)
00045 {
00046 *s = vil3d_trilin_interp_raw(p.x(),p.y(),p.z(),
00047 im_data,istep,jstep,kstep);
00048 }
00049 }
00050 }
00051
00052
00053
00054
00055
00056
00057
00058
00059 template<class T>
00060 inline void vimt3d_sample_transformed_blob_safe(
00061 const vil3d_image_view<T>& image,
00062 const vimt3d_transform_3d& i2i,
00063 const vcl_vector<vil3d_chord>& chords,
00064 vnl_vector<double>& sample,
00065 T outval=0)
00066 {
00067 double *s = sample.data_block();
00068
00069 vcl_vector<vil3d_chord>::const_iterator c = chords.begin();
00070 vgl_vector_3d<double> dp = i2i(1,0,0)-i2i.origin();
00071
00072 vcl_ptrdiff_t istep = image.istep();
00073 vcl_ptrdiff_t jstep = image.jstep();
00074 vcl_ptrdiff_t kstep = image.kstep();
00075 unsigned ni=image.ni(),nj=image.nj(),nk=image.nk();
00076 const T* im_data = image.origin_ptr();
00077
00078 for (;c!=chords.end();++c)
00079 {
00080
00081 vgl_point_3d<double> p=i2i(c->start_x(),c->y(),c->z());
00082 double *s_end = s+c->length();
00083 for (;s!=s_end;++s,p+=dp)
00084 {
00085 *s = vil3d_trilin_interp_safe(p.x(),p.y(),p.z(),
00086 im_data,ni,nj,nk,
00087 istep,jstep,kstep,outval);
00088 }
00089 }
00090 }
00091
00092 #endif // vimt3d_sample_transformed_blob_h_