contrib/brl/bseg/brip/brip_filter_bank.h
Go to the documentation of this file.
00001 // This is brl/bseg/brip/brip_filter_bank.h
00002 #ifndef brip_filter_bank_h_
00003 #define brip_filter_bank_h_
00004 //-----------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \author J.L. Mundy
00008 // \brief A set of filter operations based on Gaussian derivatives
00009 //
00010 // Provides a set of 2nd derivative filter responses at each pixel over 
00011 // scale and orientation. The scale values are spaced at harmonic 
00012 // intervals across the range. That is, the scale ratio is the nth root
00013 // of the scale range. The input image is downsampled to form the scale
00014 // pyramid. The anisotropic (in general) 2nd derivative filter is applied 
00015 // with the same max and min Gaussian standard deviations, lambda0,
00016 // and lambda1, at each level of the scale pyramid. At each level a search
00017 // over orientations is made and the maximum response is retained in the
00018 // filter response output. If the operator is isotropic, i.e., 
00019 // lambda0 == lambda1, no search over orientations is carried out.
00020 // \verbatim
00021 //  Modifications
00022 //  none
00023 // // \endverbatim
00024 //
00025 //-----------------------------------------------------------------------------
00026 #include <vcl_vector.h>
00027 #include <vil/vil_image_view.h>
00028 #include <vil/vil_pyramid_image_view.h>
00029 #include <vcl_iostream.h>
00030 
00031 class brip_filter_bank
00032 {
00033  public:
00034 
00035   brip_filter_bank(): ni_(0), nj_(0),n_levels_(0), scale_ratio_(1.0),
00036     lambda0_(1.0f), lambda1_(1.0f), theta_interval_(0.0f), 
00037     cutoff_ratio_(0.01f){}
00038 
00039   brip_filter_bank(unsigned n_levels, double scale_range, float lambda0,
00040                    float lambda1, float theta_interval, float cuttoff_ratio);
00041 
00042 
00043   brip_filter_bank(unsigned n_levels, double scale_range, float lambda0,
00044                    float lambda1, float theta_interval, float cuttoff_ratio,
00045                    vil_image_view<float> const& image);
00046 
00047   ~brip_filter_bank() {}
00048   //: set image after construction
00049   void set_image(vil_image_view<float> const& image);
00050   //: accessors
00051   unsigned ni() const {return ni_;}
00052   unsigned nj() const {return nj_;}
00053   unsigned n_levels() const {return n_levels_;}
00054   double scale_ratio() const {return scale_ratio_;}
00055   float lambda0() const {return lambda0_;}
00056   float lambda1() const {return lambda1_;}
00057   float theta_interval() const {return theta_interval_;}
00058   //: the strip width around the image with invalid filter values
00059   unsigned invalid_border() const;
00060   //: filter response for scale level
00061   vil_image_view<float>& response(unsigned int scale_level){
00062     return filter_responses_[scale_level];}
00063   //: full set of filter responses
00064   vcl_vector<vil_image_view<float> > responses() const{
00065     return filter_responses_;}
00066   //: save filter responses as individual images  
00067   bool save_filter_responses(vcl_string const& dir) const;
00068  protected:
00069   //: internal methods
00070   void construct_scale_pyramid();
00071   void compute_filter_responses();
00072 
00073   //: members
00074   unsigned ni_, nj_;
00075   unsigned n_levels_;
00076   double scale_ratio_;
00077   float lambda0_;
00078   float lambda1_;
00079   float theta_interval_;
00080   float cutoff_ratio_;
00081   vil_pyramid_image_view<float> scale_pyramid_;
00082   //: signed filter response in direction with maximum response
00083   vcl_vector<vil_image_view<float> > filter_responses_;
00084 };
00085 
00086 vcl_ostream&  operator<<(vcl_ostream& s, brip_filter_bank const& r);
00087 
00088 #endif // brip_filter_bank_h_