00001 #ifndef vimt_image_2d_h_ 00002 #define vimt_image_2d_h_ 00003 //: 00004 // \file 00005 // \brief A base class for arbitrary 2D images+transform 00006 // \author Tim Cootes 00007 00008 #include <vimt/vimt_image.h> 00009 #include <vimt/vimt_transform_2d.h> 00010 #include <vil/vil_image_view_base.h> 00011 #include <vgl/vgl_box_2d.h> 00012 class mil_transform_2d; 00013 00014 //: A base class for arbitrary 2D images 00015 // world2im() gives transformation from world to image co-ordinates 00016 class vimt_image_2d : public vimt_image 00017 { 00018 protected: 00019 vimt_transform_2d world2im_; 00020 00021 vimt_image_2d(const vimt_transform_2d& w2i) : world2im_(w2i) {}; 00022 00023 public: 00024 //: Dflt ctor 00025 vimt_image_2d() {}; 00026 00027 //: Destructor 00028 virtual ~vimt_image_2d() {}; 00029 00030 //: Return dimensionality of image 00031 virtual unsigned n_dims() const { return 2; } 00032 00033 //: Return vector indicating size of image in pixels 00034 // 2D image is v[0] x v[1] 00035 // Somewhat inefficient: Only use when you absolutely have to. 00036 // Usually one only needs to know the size once one knows the exact type. 00037 virtual vcl_vector<unsigned> image_size() const; 00038 00039 //: Return vectors defining bounding box containing image in world co-ords 00040 virtual void world_bounds(vcl_vector<double>& b_lo, 00041 vcl_vector<double>& b_hi) const; 00042 00043 //: Current world-to-image transformation 00044 const vimt_transform_2d& world2im() const { return world2im_; } 00045 00046 //: Current world-to-image transformation 00047 vimt_transform_2d& world2im() { return world2im_; } 00048 00049 //: Set world-to-image transformation 00050 // \deprecated in favour of non-const world2im() 00051 void set_world2im(const vimt_transform_2d& w2i) { world2im_ = w2i ;} 00052 00053 //: Baseclass view of image 00054 virtual const vil_image_view_base& image_base() const = 0; 00055 00056 //: Name of the class 00057 virtual vcl_string is_a() const { return "vimt_image_2d"; } 00058 00059 //: Does the name of the class match the argument? 00060 virtual bool is_class(vcl_string const& s) const 00061 { return s=="vimt_image_2d" || vimt_image::is_class(s); } 00062 }; 00063 00064 00065 //: Related Functions 00066 00067 //: Return bounding box containing input image in world co-ords, but more conveniently as a box 00068 // This may be more convenient than the similar class method in generic vector form, 00069 // as the latter is for a general number of dimensions 00070 vgl_box_2d<double> world_bounding_box(const vimt_image_2d& img); 00071 00072 00073 //: Translate the image so that its centre is at the origin of the world coordinate system. 00074 void vimt_centre_image_at_origin(vimt_image_2d& image); 00075 00076 00077 #endif // vimt_image_2d_h_
1.4.4