00001 // This is core/vpdl/vpdt/vpdt_gaussian_detector.h 00002 #ifndef vpdt_gaussian_detector_h_ 00003 #define vpdt_gaussian_detector_h_ 00004 //: 00005 // \file 00006 // \brief Detectors applying to Gaussians 00007 // \author Matt Leotta (mleotta@lems.brown.edu) 00008 // \date March 11, 2009 00009 // 00010 // \verbatim 00011 // Modifications 00012 // <None yet> 00013 // \endverbatim 00014 00015 #include <vpdl/vpdt/vpdt_field_traits.h> 00016 00017 //: A simple Mahalanobis distance detector for a Gaussian 00018 // Detects samples that lie within some Mahalanobis distance 00019 template <class gaussian_type> 00020 class vpdt_gaussian_mthresh_detector 00021 { 00022 public: 00023 //: the functor return type 00024 typedef bool return_type; 00025 //: the functor return type 00026 static const unsigned int return_dim = 1; 00027 //: the distribution operated on by the detector 00028 typedef gaussian_type distribution_type; 00029 00030 //: the data type to represent a point in the field 00031 typedef typename gaussian_type::field_type F; 00032 //: define the scalar type (normally specified by template parameter T) 00033 typedef typename vpdt_field_traits<F>::scalar_type T; 00034 00035 //: Constructor 00036 vpdt_gaussian_mthresh_detector(const T& thresh=T(2.5)) 00037 : sqr_threshold(thresh*thresh) {} 00038 00039 //: The main function 00040 // \retval true if the Mahalanobis distance is less than the threshold 00041 bool operator() (const gaussian_type& g, const F& sample, bool& result) const 00042 { 00043 result = g.sqr_mahal_dist(sample) < sqr_threshold; 00044 return true; 00045 } 00046 00047 //: the threshold on Mahalanobis distance 00048 T sqr_threshold; 00049 }; 00050 00051 00052 #endif // vpdt_gaussian_detector_h_