contrib/mul/vimt3d/vimt3d_gauss_reduce.h
Go to the documentation of this file.
00001 // This is mul/vimt3d/vimt3d_gauss_reduce.h
00002 #ifndef vimt3d_gauss_reduce_h_
00003 #define vimt3d_gauss_reduce_h_
00004 //:
00005 // \file
00006 // \brief Function to smooth and sub-sample 3D images
00007 // \author Kevin de Souza
00008 
00009 #include <vimt3d/vimt3d_image_3d_of.h>
00010 #include <vil3d/algo/vil3d_gauss_reduce.h>
00011 
00012 //: Smooth and subsample src_im to produce dest_im
00013 //  Applies filter in i,j and k directions, then samples every other pixel.
00014 //  Resulting image is (ni+1)/2 x (nj+1)/2 x (nk+1)/2.
00015 //  Transform is modified by a scaling factor of 0.5.
00016 //  An image can be reduced in-place, by having src_im and dest_im pointing to the same image.
00017 //  Requires client to provide 2 workspace images.
00018 // \sa vimt3d_gauss_reduce()
00019 template<class T>
00020 void vimt3d_gauss_reduce(const vimt3d_image_3d_of<T>& src,
00021                          vimt3d_image_3d_of<T>&       dst,
00022                          vimt3d_image_3d_of<T>&       work1,
00023                          vimt3d_image_3d_of<T>&       work2)
00024 {
00025   vil3d_gauss_reduce(src.image(), dst.image(), work1.image(), work2.image());
00026 
00027   vimt3d_transform_3d scaling;
00028   scaling.set_zoom_only(0.5, 0.5, 0.5, 0.0, 0.0, 0.0);
00029   dst.set_world2im(scaling * src.world2im());
00030 }
00031 
00032 
00033 //: Smooth and subsample src_im to produce dest_im
00034 //  This simple overload does not require client to provide 2 workspace images.
00035 // \sa vimt3d_gauss_reduce()
00036 template<class T>
00037 void vimt3d_gauss_reduce(const vimt3d_image_3d_of<T>& src,
00038                          vimt3d_image_3d_of<T>&       dst)
00039 {
00040   // Workspace images are resized as required by vil3d_gauss_reduce()
00041   vimt3d_image_3d_of<T> work1;
00042   vimt3d_image_3d_of<T> work2;
00043   vimt3d_gauss_reduce(src, dst, work1, work2);
00044 }
00045 
00046 
00047 #endif // vimt3d_gauss_reduce_h_