contrib/brl/bseg/brip/brip_max_scale_response.h
Go to the documentation of this file.
00001 // This is brl/bseg/brip/brip_max_scale_response.h
00002 #ifndef brip_scale_extrema_h_
00003 #define brip_scale_extrema_h_
00004 //:
00005 // \file
00006 // \brief Compute an image with values of scale according to maximum gradient matrix trace response
00007 // \author J. L. Mundy, March 18, 2008
00008 //
00009 // The trace of the gradient matrix,
00010 //   (Ix)^2   IxIy
00011 //   IxIy     (Iy)^2
00012 // is invariant to feature orientation
00013 // The input can be either an image pyramid or a base image
00014 // In the latter case a pyramid is generated as input to the scale max response
00015 // search. The interval between scales is uniform on according to the
00016 // logarithm of scale ratios. For example if the scale range is
00017 // from 1 to 8 and the scale ratio is sqrt(2), the scale intervals are:
00018 // 1, 1.4, 2, 2.8, 4, 5.6, 8, i.e.,
00019 // 8/4 = 2, 2^(0.5) = 1.4, 4*1.4 = 5.6
00020 //
00021 #include <vil/vil_image_view.h>
00022 #include <vcl_vector.h>
00023 
00024 template <class T>
00025 class brip_max_scale_response
00026 {
00027  public:
00028   //:compute pyramid from base
00029   brip_max_scale_response( vil_image_view<T> const& base_image,
00030                            double scale_ratio,
00031                            double max_scale);
00032   //: a pre-computed pyramid
00033   brip_max_scale_response( vcl_vector<vil_image_view<T> > const& pyramid);
00034 
00035   //: The vector of image scales
00036   vcl_vector<float> scales() const {return pyramid_scales_;}
00037 
00038   //: A pyramid from a base image with scales according to this->scales()
00039   vcl_vector<vil_image_view<T> > image_pyramid(vil_image_view<T> const& base);
00040 
00041   //: a single image with the natural scale at each pixel
00042   vil_image_view<float> scale_base();
00043 
00044   //: a pyramid of natural scales at each pixel
00045   vcl_vector<vil_image_view<float> > scale_pyramid();
00046 
00047   //: a mask that is true if the natural scale of pixel at a pyramid level is the same as the scale of the pyramid level
00048   vcl_vector<vil_image_view<vxl_byte> > mask_pyramid();
00049 
00050   //: for debugging purposes -- not normally used
00051   vcl_vector<vil_image_view<float> > trace_pyramid() const {return trace_;}
00052  protected:
00053   //internal functions
00054   brip_max_scale_response(): trace_valid_(false){}
00055   void compute_trace_pyramid();
00056   vcl_vector<float> pyramid_scales_;
00057   vcl_vector<vil_image_view<float> > grey_pyramid_;
00058   bool trace_valid_;
00059   vcl_vector<vil_image_view<float> > trace_;
00060 };
00061 
00062 #endif // brip_scale_extrema_h_