Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
clfGauss.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003, 2004 (see file CONTACTS for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef CLFGAUSS_HH_
26 #define CLFGAUSS_HH_
27 
28 #include <Base/Common/BIASpragmaStart.hh>
29 #include <Base/Image/Image.hh>
30 #include <OpenCLFramework/clfOpenCL.hh>
31 #include <OpenCLFramework/clfContext.hh>
32 #include <OpenCLFramework/Filter/clfFilter.hh>
33 
34 namespace BIAS {
35 
36  template <class InputStorageType, class OutputStorageType>
37  class BIASOpenCLFramework_EXPORT clfGauss : public clfFilter<InputStorageType, OutputStorageType> {
38  public:
39  clfGauss(clfContext *ctx);
40  virtual ~clfGauss();
41 
42  virtual int Filter(clfImage2D *src, clfImage2D *dst);
43 
44  virtual int Build(unsigned int size);
45 
46 
47  inline void SetSigma(const double si) {
48  GaussSigma_=si;
49  CalculateKernels_(GaussSigma_, GaussRatio_);
50  }
51 
52  inline double GetSigma() const { return GaussSigma_; }
53 
54  inline void SetRatio(const double ratio) {
55  GaussRatio_=ratio;
56  CalculateKernels_(GaussSigma_, GaussRatio_);
57  }
58 
59  inline double GetRatio() const { return GaussRatio_; }
60 
61  /** define the half win size of the kernel, if AdjustSigma is true
62  sigma is computed according to the cut-off ratio, otherwise the ratio
63  is adapted to the sigma */
64  inline void SetWinSize(const int ws, bool AdjustSigma=true)
65  {
66  int hws = ws >> 1;
67  if (AdjustSigma) {
68  GaussSigma_ = sqrt((double)hws*(double)hws/(-2.0*log(GaussRatio_)));
69  } else {
70  GaussRatio_ = 0.5*(exp(((double)hws*(double)hws)
71  /(-2.0*(GaussSigma_)*(GaussSigma_)))+
72  exp(((double)(hws+1.0)*(double)(hws+1.0))
73  /(-2.0*(GaussSigma_)*(GaussSigma_)))) ;
74  }
75  }
76 
77 
78  // these are interfaces for class Tracker is Track is instantiated
79  // with out param object
80  double GetSigma(){ return GaussSigma_;}
81  double GetRatio(){ return GaussRatio_;}
82 
83  protected:
84 
85  /// calculates the kernel
86  virtual void CalculateKernels_(double Sigma, double Ratio);
87 
88  double GaussSigma_;
89  double GaussRatio_;
90 
91  double LastSigma_;
92  double LastRatio_;
93 
96 
97  private:
98 
99  };
100 
101 } /* namespace BIAS */
102 #include <Base/Common/BIASpragmaEnd.hh>
103 #endif /* CLFGAUSS_HH_ */
double LastRatio_
Definition: clfGauss.hh:92
OpenCL Image2D wrapper.
Definition: clfImage2D.hh:46
void SetRatio(const double ratio)
Definition: clfGauss.hh:54
double GaussRatio_
Definition: clfGauss.hh:89
double GetRatio()
Definition: clfGauss.hh:81
OpenCL Context wrapper.
Definition: clfContext.hh:49
double GetSigma() const
Definition: clfGauss.hh:52
double GetSigma()
Definition: clfGauss.hh:80
double LastSigma_
Definition: clfGauss.hh:91
void SetSigma(const double si)
Definition: clfGauss.hh:47
void SetWinSize(const int ws, bool AdjustSigma=true)
define the half win size of the kernel, if AdjustSigma is true sigma is computed according to the cut...
Definition: clfGauss.hh:64
double GaussSigma_
Definition: clfGauss.hh:88
double GetRatio() const
Definition: clfGauss.hh:59