contrib/mul/vimt/vimt_image_pyramid.h
Go to the documentation of this file.
00001 // This is mul/vimt/vimt_image_pyramid.h
00002 #ifndef vimt_image_pyramid_h_
00003 #define vimt_image_pyramid_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Pyramid of images of arbitrary type
00010 // \author Tim Cootes
00011 
00012 #include <vcl_vector.h>
00013 #include <vcl_iosfwd.h>
00014 class vimt_image;
00015 
00016 //: Pyramid of images of arbitrary type
00017 class vimt_image_pyramid
00018 {
00019   vcl_vector<vimt_image*> image_;
00020   double base_pixel_width_;
00021   double scale_step_;
00022 
00023   void deleteImages();
00024  public:
00025   //: Dflt ctor
00026   vimt_image_pyramid();
00027 
00028   //: Copy ctor
00029   // Makes a shallow copy of each vimt_image object, not of the
00030   // underlying data
00031   vimt_image_pyramid(const vimt_image_pyramid &);
00032 
00033   //: Destructor
00034   virtual ~vimt_image_pyramid();
00035 
00036   //: Resize to n_levels pyramid
00037   //  Each level of which is a clone of im_type
00038   void resize(int n_levels, const vimt_image& im_type);
00039 
00040   //: Lowest level (highest resolution image) of pyramid
00041   int lo() const;
00042 
00043   //: Highest level (lowest resolution image) of pyramid
00044   int hi() const;
00045 
00046   //: Number of levels
00047   int n_levels() const;
00048 
00049   //: Image at level L
00050   vimt_image& operator()(int L);
00051 
00052   //: Image at level L
00053   const vimt_image& operator()(int L) const;
00054 
00055   //: Copy operator
00056   // Makes a shallow copy of each vimt_image object, not of the
00057   // underlying data
00058   const vimt_image_pyramid& operator=(const vimt_image_pyramid& that);
00059 
00060   //: Take a deep copy of the given pyramid
00061   void deep_copy(const vimt_image_pyramid& im_pyr);
00062 
00063   //: Mean width (in world coordinates) of pixels at level zero
00064   double base_pixel_width() const;
00065 
00066   //: Scaling per level
00067   //  Pixels at level L have width
00068   //  basePixelWidth() * scaleStep()^L
00069   double scale_step() const;
00070 
00071   //: Access to image data
00072   //  Should only be used by pyramid builders
00073   vcl_vector<vimt_image*>& data();
00074 
00075   //: Define pixel widths
00076   void set_widths(double base_pixel_width, double scale_step);
00077 
00078   void print_summary(vcl_ostream& os) const;
00079 
00080   //: Print whole of each image to os
00081   void print_all(vcl_ostream& os) const;
00082 };
00083 
00084 //: Convert an image pyramid into a flat image containing each layer.
00085 // E.g. a three layer 2d image pyramid with scale factor 2.0
00086 // would be converted to an image looking like
00087 // \verbatim
00088 // ________________
00089 // |11111111222233|
00090 // |111111112222  |
00091 // |11111111      |
00092 // |11111111      |
00093 // ----------------
00094 // \endverbatim
00095 template <class T> void vimt_image_pyramid_flatten(T& out, const vimt_image_pyramid & in);
00096 
00097 vcl_ostream& operator<<(vcl_ostream& os, const vimt_image_pyramid& im_pyr);
00098 vcl_ostream& operator<<(vcl_ostream& os, const vimt_image_pyramid* im_pyr);
00099 void vsl_print_summary(vcl_ostream& os, const vimt_image_pyramid& im_pyr);
00100 void vsl_print_summary(vcl_ostream& os, const vimt_image_pyramid* im_pyr);
00101 
00102 #endif // vimt_image_pyramid_h_