contrib/brl/bbas/bsta/bsta_otsu_threshold.h
Go to the documentation of this file.
00001 #ifndef bsta_otsu_threshold_h_
00002 #define bsta_otsu_threshold_h_
00003 //:
00004 // \file
00005 // \brief Implements Otsu's threshold method for 1D distribution and 2 classes
00006 // \author Vishal Jain, (vj@lems.brown.edu)
00007 // \date April 09, 2005
00008 //
00009 //  The Otsu thresholding method maximizes the between class variance by
00010 //  an exhaustive linear scan over the histogram bin indices
00011 //
00012 // \verbatim
00013 //  Modifications
00014 //   Templated and moved up to bsta - J.L. Mundy June 29, 2005
00015 // \endverbatim
00016 
00017 #include<vcl_vector.h>
00018 #include<bsta/bsta_histogram.h>
00019 
00020 template <class T> class bsta_otsu_threshold
00021 {
00022  public:
00023   // constructor
00024   bsta_otsu_threshold(bsta_histogram<T> const& hist);
00025   //: takes vector of data as input
00026   bsta_otsu_threshold(vcl_vector<T> data, T low , T high);
00027   // destructor
00028   ~bsta_otsu_threshold();
00029 
00030   unsigned bin_threshold() const;
00031 
00032   T threshold() const {return distribution_1d_.avg_bin_value(this->bin_threshold());}
00033 
00034  protected:
00035   //: default constructor doesn't make sense
00036   bsta_otsu_threshold() : distribution_1d_(bsta_histogram<T>(0,0)){}
00037 
00038   bsta_histogram<T> distribution_1d_;
00039 };
00040 
00041 #define BSTA_OTSU_THRESHOLD_INSTANTIATE(T) extern "Please #include <bsta/bsta_otsu_threshold.txx>"
00042 
00043 #endif // bsta_otsu_threshold_h_