iRoCS Toolbox  1.1.0
Kernel_DS_TRIA.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title: Kernel_DS_TRIA.hh
26 ** $RCSfile$
27 ** $Revision: 740 $$Name$
28 ** $Date: 2005-07-19 15:42:59 +0200 (Tue, 19 Jul 2005) $
29 ** Copyright: LGPL $Author: haasdonk $
30 ** Description: DS_TRIA kernel functor
31 ** Distance-Substitution-TRIA Kernel
32 **
33 **-------------------------------------------------------------------------
34 **
35 ** $Log$
36 ** Revision 1.2 2005/07/19 13:42:59 haasdonk
37 ** adapted header for automatic CVS-Information extraction
38 **
39 **
40 **************************************************************************/
41 
42 
43 #ifndef KERNEL_DS_TRIA_HH
44 #define KERNEL_DS_TRIA_HH
45 
46 #ifdef HAVE_CONFIG_H
47 #include <config.hh>
48 #endif
49 
50 // std includes
51 #include <cmath>
52 #include <map>
53 #include <set>
54 #include <string>
55 
56 // libsvmtl includes
57 #include "ProgressReporter.hh"
58 
59 // requirements of template parameters
62 
63 namespace svt
64 {
65  template< typename KERNEL >
67  {
68 
69  public:
70  Kernel_DS_TRIA(double beta=2.)
71  :p_beta(beta)
72  {};
73 
75  {};
76 
77  void setBeta( double beta) { p_beta = beta; }
78  double beta() const { return p_beta; }
79 
80 // old updateCache syntax
81 
82  template< typename ForwardIter, typename Accessor>
83  void updateCache( const ForwardIter& fvBegin,
84  const ForwardIter& fvEnd,
85  Accessor accessor,
86  ProgressReporter* pr = 0) const
87  {
88  _kernel.updateCache(fvBegin,fvEnd,accessor,pr);
89 
90  }
91 
92 // new updateCache syntax
93  template< typename ForwardIter1, typename Accessor1,
94  typename ForwardIter2, typename Accessor2>
95  void updateCache( const ForwardIter1& fvBegin1,
96  const ForwardIter1& fvEnd1,
97  Accessor1 accessor1,
98  const ForwardIter2& fvBegin2,
99  const ForwardIter2& fvEnd2,
100  Accessor2 accessor2,
101  ProgressReporter* pr = 0) const
102  {
103  _kernel.updateCache(fvBegin1,fvEnd1,accessor1,
104  fvBegin2,fvEnd2,accessor2,
105  pr);
106  }
107 
108  void clearCache() const
109  {
110  // nothing to do here
111  }
112 
113  template< typename FV>
114  double k_function( const FV& x, const FV& y) const
115  {
118  return -pow(_kernel.k_function(x,y),p_beta/2);
119  };
120 
121  template<typename STDATA>
122  void loadParameters( STDATA& stData)
123  {
125  if( stData.valueExists( "beta"))
126  {
127  stData.getValue( "beta", p_beta);
128  }
129  _kernel.loadParameters(stData);
130  };
131 
132  template<typename STDATA>
133  void saveParameters( STDATA& stData) const
134  {
136  _kernel.saveParameters(stData);
137  stData.setValue( "kernel_type", name());
138  stData.setValue( "beta", p_beta);
139 
140  };
141 
142  static std::string name()
143  {
144  return std::string("DS_tria_")+KERNEL::name();
145  }
146 
147  static const char* description()
148  {
149  return "triangular distance substitution"
150  " kernel: -d^beta for 0<beta<=2";
151  }
152 
153  static void getParamInfos( std::vector<ParamInfo>& p)
154  {
155  p.push_back(
156  ParamInfo( "beta", "b", "value",
157  "beta for DS-tria-kernel. (default 2.0)"));
158  KERNEL::getParamInfos(p);
159 
160  }
161 
162  protected:
163  KERNEL _kernel;
164  double p_beta;
165  };
166 }
167 
168 #endif
169 
170 
171 
172 
173 
174 
Kernel_DS_TRIA(double beta=2.)
#define CHECK_MEMBER_TEMPLATE(c)
void clearCache() const
static std::string name()
static const char * description()
void saveParameters(STDATA &stData) const
static void getParamInfos(std::vector< ParamInfo > &p)
double beta() const
void updateCache(const ForwardIter &fvBegin, const ForwardIter &fvEnd, Accessor accessor, ProgressReporter *pr=0) const
void updateCache(const ForwardIter1 &fvBegin1, const ForwardIter1 &fvEnd1, Accessor1 accessor1, const ForwardIter2 &fvBegin2, const ForwardIter2 &fvEnd2, Accessor2 accessor2, ProgressReporter *pr=0) const
void setBeta(double beta)
double k_function(const FV &x, const FV &y) const
The ParamInfo class contains informations about one parameter like key, help text, guiHints etc.
Definition: ParamInfo.hh:82
void loadParameters(STDATA &stData)
Polynomial< CoeffT > pow(const Polynomial< CoeffT > &p, int exponential)
Power operator.