Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vimt_gaussian_pyramid_builder_2d.h

Go to the documentation of this file.
00001 // This is mul/vimt/vimt_gaussian_pyramid_builder_2d.h
00002 #ifndef vimt_gaussian_pyramid_builder_2d_h_
00003 #define vimt_gaussian_pyramid_builder_2d_h_
00004 //:
00005 // \file
00006 // \brief Build gaussian pyramids of vimt_image_2d_of<T>
00007 // \author Tim Cootes
00008 
00009 #include <vsl/vsl_binary_io.h>
00010 #include <vcl_string.h>
00011 #include <vimt/vimt_image_2d_of.h>
00012 #include <vimt/vimt_image_pyramid_builder.h>
00013 
00014 //: Build gaussian pyramids of vimt_image_2d_of<T>
00015 //  Smooth with a gaussian filter (1-5-8-5-1 by default)
00016 //  and subsample so that image at level i-1 is half the
00017 //  size of that at level i
00018 template <class T>
00019 class vimt_gaussian_pyramid_builder_2d : public vimt_image_pyramid_builder
00020 {
00021   int max_levels_;
00022 
00023   mutable vimt_image_2d_of<T> work_im_;
00024 
00025   //: Filter width (usually 5 for a 15851 filter, or 3 for a 121 filter)
00026   unsigned filter_width_;
00027 
00028   //:Minimum size in X direction of top layer of pyramid.
00029   unsigned minXSize_;
00030 
00031   //:Minimum size in Y direction of top layer of pyramid.
00032   unsigned minYSize_;
00033 
00034  protected:
00035   //: Checks pyramid has at least n levels of correct type
00036   void check_pyr(vimt_image_pyramid& im_pyr,  int n_levels) const;
00037 
00038   //: Deletes all data in im_pyr
00039   void empty_pyr(vimt_image_pyramid& im_pyr) const;
00040 
00041  public:
00042   //: Dflt ctor
00043   vimt_gaussian_pyramid_builder_2d();
00044 
00045   //: Destructor
00046   virtual ~vimt_gaussian_pyramid_builder_2d();
00047 
00048   //: Current filter width
00049   unsigned filter_width() const { return filter_width_; }
00050 
00051   //: Set current filter width (must be 3 or 5 at present)
00052   void set_filter_width(unsigned);
00053 
00054   //: Create new (empty) pyramid on heap.
00055   //  Caller responsible for its deletion
00056   virtual vimt_image_pyramid* new_image_pyramid() const;
00057 
00058   //: Define maximum number of levels to build.
00059   //  Limits levels built in subsequent calls to build()
00060   //  Useful efficiency measure.  As build() only takes
00061   //  a shallow copy of the original image, using
00062   //  max_l=1 avoids any copying or smoothing.
00063   virtual void set_max_levels(int max_l);
00064 
00065   //: Get the current maximum number levels allowed
00066   virtual int max_levels() const;
00067 
00068   //: Build pyramid
00069   virtual void build(vimt_image_pyramid&, const vimt_image&) const;
00070 
00071   //: Extend pyramid.
00072   // The first layer of the pyramid must already be set.
00073   // Scale steps must be equal.
00074   virtual void extend(vimt_image_pyramid&) const;
00075 
00076   //: Smooth and subsample src_im to produce dest_im.
00077   //  Applies filter in x and y, then samples every other pixel.
00078   //  Filter width defined by set_filter_width()
00079   void gauss_reduce(const vimt_image_2d_of<T>& src_im,
00080                     vimt_image_2d_of<T>& dest_im) const;
00081 
00082   //: Scale step between levels
00083   virtual double scale_step() const;
00084 
00085   //: Get the minimum Y size of the top layer of the pyramid.
00086   // Defaults to 5.
00087   unsigned min_y_size() const { return minYSize_;}
00088 
00089   //: Get the minimum X size of the top layer of the pyramid.
00090   // Defaults to 5.
00091   unsigned min_x_size() const { return minXSize_;}
00092 
00093   //: Set the minimum size of the top layer of the pyramid
00094   virtual void set_min_size(unsigned X, unsigned Y) { minYSize_ = Y; minXSize_ = X;}
00095 
00096   //: Version number for I/O
00097   short version_no() const;
00098 
00099   //: Name of the class
00100   virtual vcl_string is_a() const;
00101 
00102   //: Does the name of the class match the argument?
00103   virtual bool is_class(vcl_string const& s) const;
00104 
00105   //: Create a copy on the heap and return base class pointer
00106   virtual vimt_image_pyramid_builder* clone() const;
00107 
00108   //: Print class to os
00109   virtual void print_summary(vcl_ostream& os) const;
00110 
00111   //: Save class to binary file stream
00112   virtual void b_write(vsl_b_ostream& bfs) const;
00113 
00114   //: Load class from binary file stream
00115   virtual void b_read(vsl_b_istream& bfs);
00116 };
00117 
00118 #endif // vimt_gaussian_pyramid_builder_2d_h_

Generated on Thu Jan 10 14:43:58 2008 for contrib/mul/vimt by  doxygen 1.4.4