contrib/mul/vimt3d/vimt3d_load.h
Go to the documentation of this file.
00001 // This is mul/vimt3d/vimt3d_load.h
00002 #ifndef vimt3d_load_h_
00003 #define vimt3d_load_h_
00004 //:
00005 // \file
00006 // \author Ian Scott
00007 
00008 #include <vil3d/vil3d_image_resource.h>
00009 #include <vimt3d/vimt3d_transform_3d.h>
00010 #include <vimt3d/vimt3d_image_3d_of.h>
00011 #include <vil3d/vil3d_load.h>
00012 #include <vil3d/vil3d_convert.h>
00013 
00014 //: Create a transform from the properties of image resource.
00015 // The following parameters allow the use of this method in legacy code:
00016 // \param use_millimetres    if true load transform in millimetres (uses metres by default)
00017 vimt3d_transform_3d vimt3d_load_transform(const vil3d_image_resource_sptr &im,
00018                                           bool use_millimetres=false);
00019 
00020 //: Load image from path into given image (forcing to given pixel type)
00021 template<class T>
00022 void vimt3d_load(const vcl_string& path,
00023                  vimt3d_image_3d_of<T>& image,
00024                  bool use_millimetres=false)
00025 {
00026   vil3d_image_resource_sptr ir = vil3d_load_image_resource(path.c_str());
00027   if (ir.ptr()==0)
00028   {
00029     image.image().set_size(0,0,0);
00030     return;
00031   }
00032 
00033   image.image() = vil3d_convert_cast(T(), 
00034                                      ir->get_view(0,ir->ni(),0,ir->nj(),0,ir->nk()));
00035 
00036   image.set_world2im(vimt3d_load_transform(ir,use_millimetres));
00037 }
00038 
00039 #endif // vimt3d_load_h_