Go to the documentation of this file.00001
00002 #ifndef vimt3d_from_image_2d_h_
00003 #define vimt3d_from_image_2d_h_
00004
00005 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00006 #pragma interface
00007 #endif
00008
00009
00010
00011
00012
00013 #include <vnl/vnl_vector.h>
00014 #include <vil/vil_image_view.h>
00015 #include <vil3d/vil3d_image_view.h>
00016 #include <vil3d/vil3d_from_image_2d.h>
00017 #include <vimt/vimt_image_2d_of.h>
00018 #include <vimt3d/vimt3d_image_3d_of.h>
00019 #include <mbl/mbl_exception.h>
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 template <class T>
00030 inline vimt3d_image_3d_of<T> vimt3d_from_image_2d(const vimt_image_2d_of<T>& img)
00031 {
00032
00033 const vil_image_view<T>& imview2d = img.image();
00034 vil3d_image_view<T> imview3d = vil3d_from_image_2d(imview2d);
00035
00036
00037 const vimt_transform_2d& transf2d = img.world2im();
00038 vimt_transform_2d::Form form2d = transf2d.form();
00039 vimt3d_transform_3d transf3d;
00040 switch (form2d)
00041 {
00042 case vimt_transform_2d::Identity:
00043 transf3d.set_identity();
00044 break;
00045
00046 case vimt_transform_2d::Translation:
00047 {
00048 vnl_vector<double> v(2);
00049 transf2d.params(v);
00050 double tx=v(0), ty=v(1), tz=0.0;
00051 transf3d.set_translation(tx, ty, tz);
00052 break;
00053 }
00054
00055 case vimt_transform_2d::ZoomOnly:
00056 {
00057 vnl_vector<double> v(4);
00058 transf2d.params(v);
00059 double sx=v(0), sy=v(1), sz=1.0, tx=v(2), ty=v(3), tz=0.0;
00060 transf3d.set_zoom_only(sx, sy, sz, tx, ty, tz);
00061 break;
00062 }
00063
00064 default:
00065 mbl_exception_error(mbl_exception_abort("vimt3d_from_image_2d(): "
00066 "Unable to handle transforms"));
00067 break;
00068 }
00069
00070
00071 return vimt3d_image_3d_of<T>(imview3d, transf3d);
00072 }
00073
00074
00075 #endif // vimt3d_from_image_2d_h_