latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiRadialKernel.h 00027 * authors ....: Jochen Wickel 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 05.11.2001 00030 * revisions ..: $Id: ltiRadialKernel.h,v 1.6 2006/02/07 18:22:37 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_RADIAL_KERNEL 00034 #define _LTI_RADIAL_KERNEL 00035 00036 #include "ltiKernelFunctor.h" 00037 #include "ltiL2Distance.h" 00038 00039 namespace lti { 00040 00041 /** 00042 * This class defines a radial kernel functor. It is defined as 00043 * \f$ K(A,B) = \exp\left(-\frac{1}{2\sigma^2}\|A-B\|^2 \right)\f$. 00044 * 00045 * The width of the radial functions is defined through <code>sigmasq</code> 00046 * given in the parameters. 00047 */ 00048 class radialKernel: public kernelFunctor<double> { 00049 00050 public: 00051 /** 00052 * the parameters for the class distanceFunctor 00053 */ 00054 class parameters : public kernelFunctor<double>::parameters { 00055 public: 00056 /** 00057 * default constructor 00058 */ 00059 parameters(); 00060 00061 /** 00062 * constructor with initialization of the kernel width 00063 */ 00064 parameters(const double& sigma); 00065 00066 /** 00067 * copy constructor 00068 * @param other the parameters object to be copied 00069 */ 00070 parameters(const parameters& other); 00071 00072 /** 00073 * returns name of this type 00074 */ 00075 const char* getTypeName() const; 00076 00077 /** 00078 * copy the contents of a parameters object 00079 * @param other the parameters object to be copied 00080 * @return a reference to this parameters object 00081 */ 00082 parameters& copy(const parameters& other); 00083 00084 /** 00085 * returns a pointer to a clone of the parameters 00086 */ 00087 virtual functor::parameters* clone() const; 00088 00089 /** 00090 * write the parameters in the given ioHandler 00091 * @param handler the ioHandler to be used 00092 * @param complete if true (the default) the enclosing begin/end will 00093 * be also written, otherwise only the data block will be written. 00094 * @return true if write was successful 00095 */ 00096 virtual bool write(ioHandler& handler, 00097 const bool complete=true) const; 00098 00099 /** 00100 * read the parameters from the given ioHandler 00101 * @param handler the ioHandler to be used 00102 * @param complete if true (the default) the enclosing begin/end will 00103 * be also written, otherwise only the data block will be written. 00104 * @return true if write was successful 00105 */ 00106 virtual bool read(ioHandler& handler,const bool complete=true); 00107 00108 # ifdef _LTI_MSC_6 00109 /** 00110 * this function is required by MSVC only, as a workaround for a 00111 * very awful bug, which exists since MSVC V.4.0, and still by 00112 * V.6.0 with all bugfixes (so called "service packs") remains 00113 * there... This method is public due to another bug!, so please 00114 * NEVER EVER call this method directly 00115 */ 00116 bool readMS(ioHandler& handler,const bool complete=true); 00117 00118 /** 00119 * this function is required by MSVC only, as a workaround for a 00120 * very awful bug, which exists since MSVC V.4.0, and still by 00121 * V.6.0 with all bugfixes (so called "service packs") remains 00122 * there... This method is public due to another bug!, so please 00123 * NEVER EVER call this method directly 00124 */ 00125 bool writeMS(ioHandler& handler,const bool complete=true) const; 00126 # endif 00127 00128 /** 00129 * width of radial function 00130 */ 00131 double sigmasq; 00132 00133 }; 00134 00135 /** 00136 * default constructor 00137 */ 00138 radialKernel(); 00139 00140 /** 00141 * constructor with parameters initialization with the given sigma 00142 * (width of the kernel). 00143 */ 00144 radialKernel(const double& sigma); 00145 00146 /** 00147 * copy constructor 00148 * @param other the object to be copied 00149 */ 00150 radialKernel(const radialKernel& other); 00151 00152 /** 00153 * returns the name of this type ("radialKernel") 00154 */ 00155 virtual const char* getTypeName() const; 00156 00157 /** 00158 * calculate the distance between the vectors a and b 00159 * @param a the first vector<T> 00160 * @param b the second vector<T> 00161 * @return the kernel function value of the vectors 00162 */ 00163 virtual double apply(const vector<double>& a, const vector<double>& b) const; 00164 00165 /** 00166 * returns a pointer to a clone of this functor. 00167 */ 00168 virtual functor* clone() const; 00169 00170 /** 00171 * returns used parameters 00172 */ 00173 const parameters& getParameters() const; 00174 00175 protected: 00176 l2Distance<double> l2; 00177 }; 00178 00179 } 00180 00181 #endif