Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

bmrf_gamma_func.h

Go to the documentation of this file.
00001 // This is brl/bseg/bmrf/bmrf_gamma_func.h
00002 #ifndef bmrf_gamma_func_h_
00003 #define bmrf_gamma_func_h_
00004 //:
00005 // \file
00006 // \brief Gamma function object
00007 // \author Matt Leotta (mleotta@lems.brown.edu)
00008 // \date 03/11/04
00009 //
00010 // This file contains a base class for the gamma function object
00011 // and several specific functions derived from it.  These functions are used
00012 // in bmrf_epi_transform.h to compute transformations of curves along epipolar
00013 // lines.  The function returns a gamma value give alpha and time.
00014 //
00015 // \verbatim
00016 //  Modifications
00017 // \endverbatim
00018 
00019 #include <vbl/vbl_ref_count.h>
00020 #include <vcl_map.h>
00021 #include "bmrf_epi_seg_sptr.h"
00022 
00023 
00024 //: Gamma function base class
00025 class bmrf_gamma_func : public vbl_ref_count
00026 {
00027  public:
00028   bmrf_gamma_func() : vbl_ref_count() {}
00029   bmrf_gamma_func(bmrf_gamma_func const& ) : vbl_ref_count() {}
00030 
00031   //: Return the gamma value for any \p alpha and time \p t.
00032   // Calls a pure virtual function
00033   double operator () (double alpha, double t=1.0) const
00034   { return this->value(alpha, t); }
00035 
00036   //: Returns the average gamma value at time \p t
00037   virtual double mean(double t=1.0) const = 0;
00038 
00039  protected:
00040   //: Return the gamma value for any \p alpha and time \p t
00041   virtual double value(double alpha, double t) const = 0;
00042 };
00043 
00044 
00045 //: A constant gamma function
00046 class bmrf_const_gamma_func : public bmrf_gamma_func
00047 {
00048  public:
00049   //: Constructor
00050   explicit bmrf_const_gamma_func(double gamma = 0.0) : gamma_(gamma) {}
00051 
00052   //: Set the constant gamma value
00053   void set_gamma(double gamma) { gamma_ = gamma; }
00054 
00055   //: Returns the constant average gamma value at time \p t.
00056   //  Here, this value is independent of \t t
00057   double mean(double /*t*/=1.0) const { return gamma_; }
00058 
00059  protected:
00060   //: Return the constant gamma value for any \p alpha and time \p t.
00061   //  Here, gamma is independent of \p alpha and of \p t
00062   virtual double value(double /*alpha*/, double /*t*/) const { return gamma_; }
00063 
00064  private:
00065   //: The constant gamma value
00066   double gamma_;
00067 };
00068 
00069 
00070 //: A linear gamma function
00071 class bmrf_linear_gamma_func : public bmrf_gamma_func
00072 {
00073  public:
00074   //: Constructor
00075   bmrf_linear_gamma_func(double m = 0.0, double b = 0.0) : m_(m), b_(b) {}
00076 
00077   //: Set the linear function parameters
00078   void set_params(double m, double b) { m_ = m; b_ = b; }
00079 
00080   //: Return the average gamma value at time \p t
00081   //  Here, this value is independent of t
00082   virtual double mean(double /*t*/=1.0) const { return b_; }
00083 
00084  protected:
00085   //: Return the gamma value for any \p alpha and time \p t
00086   //  Here, this value is independent of t
00087   virtual double value(double alpha, double /*t*/) const { return m_*alpha+b_; }
00088 
00089  private:
00090   //: The function parameters
00091   double m_, b_;
00092 };
00093 
00094 
00095 //: A piecewise linear gamma function
00096 class bmrf_pwl_gamma_func : public bmrf_gamma_func
00097 {
00098  public:
00099   //: Constructor
00100   bmrf_pwl_gamma_func( const bmrf_epi_seg_sptr& ep1, 
00101                        const bmrf_epi_seg_sptr& ep2,
00102                        double t = 1.0 );
00103 
00104 
00105   //: Return the average gamma value at time \p t
00106   //  Here, this value is independent of t
00107   virtual double mean(double /*t*/=1.0) const;
00108 
00109  protected:
00110   //: Return the gamma value for any \p alpha and time \p t
00111   //  Here, this value is independent of t
00112   virtual double value(double alpha, double /*t*/) const;
00113 
00114  private:
00115   //: The knots
00116   vcl_map<double, double> knots_;
00117 };
00118 
00119 #endif // bmrf_gamma_func_h_

Generated on Thu Jan 10 14:51:53 2008 for contrib/brl/bseg/bmrf by  doxygen 1.4.4