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