contrib/mul/vimt/vimt_convert.h
Go to the documentation of this file.
00001 // This is mul/vimt/vimt_convert.h
00002 #ifndef vimt_convert_h_
00003 #define vimt_convert_h_
00004 
00005 //:
00006 //  \file
00007 //  \brief Various type conversion functions for vimt_image objects
00008 //  \author Tim Cootes
00009 // Note: There is a general rule that we should not duplicate 
00010 // vil classes or functions with trivial wrappers in vimt.
00011 // These conversion functions break that rule because they are
00012 // used so frequently.
00013 
00014 #include <vimt/vimt_image_2d_of.h>
00015 #include <vil/vil_convert.h>
00016 
00017 //: Converts by applying a cast
00018 // If the two pixel types are the same, the destination may only be a
00019 // shallow copy of the source.
00020 template<class srcT, class destT>
00021 void vimt_convert_cast(const vimt_image_2d_of<srcT>& src_im,
00022                        vimt_image_2d_of<destT>& dest_im)
00023 {
00024   vil_convert_cast(src_im.image(),dest_im.image());
00025   dest_im.set_world2im(src_im.world2im());
00026 }
00027 
00028 //: Converts by rounding
00029 // If the two pixel types are the same, the destination may only be a
00030 // shallow copy of the source.
00031 template<class srcT, class destT>
00032 void vimt_convert_round(const vimt_image_2d_of<srcT>& src_im,
00033                        vimt_image_2d_of<destT>& dest_im)
00034 {
00035   vil_convert_round(src_im.image(),dest_im.image());
00036   dest_im.set_world2im(src_im.world2im());
00037 }
00038 
00039 //: Convert src to byte image dest by stretching to range [0,255]
00040 template<class srcT>
00041 void vimt_convert_stretch_range(const vimt_image_2d_of<srcT>& src_im,
00042                                 vimt_image_2d_of<vxl_byte>& dest_im)
00043 {
00044   vil_convert_stretch_range(src_im.image(),dest_im.image());
00045   dest_im.set_world2im(src_im.world2im());
00046 }
00047 
00048 
00049 
00050 #endif // vimt_convert_h_