contrib/brl/bbas/bsol/bsol_distance_histogram.h

Go to the documentation of this file.
00001 #ifndef bsol_distance_histogram_h_
00002 #define bsol_distance_histogram_h_
00003 //-----------------------------------------------------------------------------
00004 //:
00005 // \file
00006 // \author J.L. Mundy
00007 // \brief A distance histogram for vsol geometry (currently lines only)
00008 //
00009 //  This histogram is for detecting distance patterns in vsol geometry.
00010 //  At present it implements only vsol_line_2d machinery.
00011 //
00012 // \verbatim
00013 //  Modifications
00014 //   Initial version May 15, 2002
00015 // \endverbatim
00016 //
00017 //-----------------------------------------------------------------------------
00018 
00019 #include <vcl_iosfwd.h>
00020 #include <vcl_vector.h>
00021 #include <vsol/vsol_line_2d_sptr.h>
00022 
00023 class bsol_distance_histogram
00024 {
00025  public:
00026   bsol_distance_histogram();
00027   bsol_distance_histogram(int nbins, double max_val);
00028   bsol_distance_histogram(int nbins,
00029                           vcl_vector<vsol_line_2d_sptr> const& lines);
00030   ~bsol_distance_histogram();
00031   //:accessors
00032   int n_bins(){return bin_counts_.size();}
00033   vcl_vector<double>& counts() {return bin_counts_;}
00034   vcl_vector<double>& values() {return bin_values_;}
00035   vcl_vector<double>& weights() {return weights_;}
00036 
00037   //:update the histogram
00038   void up_count(const double value, const double count, const double weight = 1.0);
00039 
00040   //:find the first two (non-zero) distance peaks
00041   bool distance_peaks(double& peak1, double& peak2,
00042                       double min_peak_height_ratio = 0.5);
00043 
00044 
00045   //: utility functions
00046   double min_val() const;
00047   double max_val() const;
00048   double min_count() const;
00049   double max_count() const;
00050 
00051   friend
00052     vcl_ostream& operator<<(vcl_ostream& os, const bsol_distance_histogram& h);
00053 
00054  private:
00055   //:normalize the distance values which were weighted by the line length
00056   void normalize_distance();
00057   //:perform a parabolic interpolation using adjacent bins.
00058   double interpolate_peak(int initial_peak);
00059   double delta_; //!< bin value interval
00060   vcl_vector<double> bin_counts_;//!< histogram counts
00061   vcl_vector<double> bin_values_;//!< histogram values
00062   vcl_vector<double> weights_;//!< value weights
00063 };
00064 
00065 #endif

Generated on Sun Sep 7 05:20:15 2008 for contrib/brl/bbas/bsol by  doxygen 1.5.1