LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiOgdKernels.h

00001 /*
00002  * Copyright (C) 2000, 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 .......: ltiOgdKernels.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 28.04.00
00030  * revisions ..: $Id: ltiOgdKernels.h,v 1.5 2006/02/08 11:33:42 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_OGDKERNELS_H_
00034 #define _LTI_OGDKERNELS_H_
00035 
00036 #include "ltiLinearKernels.h"
00037 
00038 namespace lti {
00039 
00040   /** 
00041    * First order Oriented Gaussian Derivative
00042    *
00043    * OGD kernels are separable (one filter pair per basis kernel)!
00044    *
00045    * You can create a "real" 2D kernel with the following code
00046    *
00047    * \code
00048    * lti::ogd1Kernel<float> ogd(5); // a kernel 5x5 with default variance
00049    *                                 // and angle
00050    * lti::kernel2D<float>   kern;    // a 2D kernel;
00051    *
00052    * kern.outerProduct(ogd.getRowFilter(0),ogd.getColFilter(0));
00053    *
00054    * \endcode
00055    *
00056    * The first basis filter of the first order OGD is:
00057    *
00058    * \f$ b_0(x,y) = -g(x,y) \frac{x}{\sigma^2}\f$
00059    *
00060    * and the second:
00061    *
00062    * \f$ b_1(x,y) = -g(x,y) \frac{y}{\sigma^2}\f$
00063    *
00064    * The used interpolation functions are \f$ \cos\theta\f$ and
00065    * \f$ \sin\theta\f$.
00066    *
00067    * If you need to calculate several channels with different directions,
00068    * calculate first the basis images and then use lti::ogd1Filter to
00069    * combine them.  This way is faster as to convolve each time the channel
00070    * with the separable kernel.
00071    */
00072   template<class T>
00073   class ogd1Kernel : public sepKernel<T> {
00074   public:
00075     /** 
00076      * Default constructor
00077      *
00078      * Creates an empty kernel.  To initialize use generate() or
00079      * generateBasisKernel().
00080      */
00081     ogd1Kernel();
00082 
00083     /** 
00084      * Constructor
00085      * @param size is the dimension of the one dimensional part (i.e. the
00086      *             kernel has dimensions size x size !)
00087      * @param theVariance variance of the kernel
00088      * @param theAngle used angle (in radians)
00089      */
00090     ogd1Kernel(const int& size,
00091                const double& theVariance =  1.4426950409,
00092                const double& theAngle = 0.0);
00093 
00094     /** 
00095      * Initialize this kernel with the specified values
00096      * @param size is the dimension of the one dimensional part (i.e. the
00097      *              kernel has dimensions size x size !)
00098      * @param theVariance variance of the kernel
00099      * @param theAngle used angle (in radians)
00100      */
00101     void generate(const int& size,
00102                   const double& theVariance,
00103                   const double& theAngle);
00104 
00105     /** 
00106      * Initialize this kernel with the specified values
00107      * @param whichBasis the steerable filter basis (for ogd1 must be 0 or 1)
00108      * @param size is the dimension of the one dimensional part (i.e. the
00109      *             kernel has dimensions size x size !)
00110      * @param theVariance variance of the kernel
00111      */
00112     void generateBasisKernel(const int& whichBasis,
00113                              const int& size,
00114                              const double& theVariance);
00115 
00116   protected:
00117     double variance;
00118     double angle;
00119   };
00120 
00121   /**
00122    * Second order Oriented Gaussian Derivative
00123    *
00124    * OGD kernels are separable! (one filter pair per basis kernel)
00125    *
00126    * The first basis filter of the second order OGD is:
00127    *
00128    * \f$ b_0(x,y) = g(x,y) \frac{x^2 - \sigma^2}{\sigma^4}\f$
00129    *
00130    * and the second:
00131    *
00132    * \f$ b_1(x,y) = g(x,y) \frac{y^2 - \sigma^2}{\sigma^4}\f$
00133    *
00134    * and the third:
00135    *
00136    * \f$ b_2(x,y) = g(x,y) \frac{xy}{\sigma^4}\f$
00137    *
00138    * The used interpolation functions are \f$ \cos^2\theta\f$,
00139    * \f$ \sin^2\theta\f$ and \f$2\cos\theta \sin\theta\f$.
00140    */
00141   template<class T>
00142   class ogd2Kernel : public sepKernel<T> {
00143   public:
00144     /** 
00145      * Default constructor.
00146      *
00147      * Creates an empty kernel.  To initialize use generate() or
00148      * generateBasisKernel().
00149      */
00150     ogd2Kernel();
00151 
00152     /**
00153      * Constructor
00154      * @param size is the dimension of the one dimensional part (i.e. the
00155      *             kernel has dimensions size x size !)
00156      * @param theVariance variance of the kernel
00157      * @param theAngle used angle (in radians)
00158      */
00159     ogd2Kernel(const int& size,
00160                const double& theVariance =  1.4426950409,
00161                const double& theAngle = 0.0);
00162 
00163     /**
00164      * Initialize this kernel with the specified values
00165      * @param size is the dimension of the one dimensional part (i.e. the
00166      *             kernel has dimensions size x size !)
00167      * @param theVariance variance of the kernel
00168      * @param theAngle used angle (in radians)
00169      */
00170     void generate(const int& size,
00171                   const double& theVariance,
00172                   const double& theAngle);
00173 
00174     /*
00175 
00176      * Initialize this kernel with the specified values
00177 
00178      *
00179 
00180      * - 0: angle is    0, corresponds to derivative in XX direction
00181 
00182      * - 1: angle is Pi/2, corresponds to derivative in YY direction
00183 
00184      * - 2: angle is Pi/4, corresponds to derivative in XY direction
00185 
00186      *
00187 
00188      * @param whichBasis the steerable filter basis
00189 
00190      *                   (for ogd2 must be 0, 1 or 2)
00191 
00192      * @param size is the dimension of the one dimensional part (i.e. the
00193 
00194      *             kernel has dimensions size x size !
00195 
00196      * @param theVariance variance of the kernel
00197 
00198      */
00199     void generateBasisKernel(const int& whichBasis,
00200                              const int& size,
00201                              const double& theVariance);
00202 
00203   protected:
00204     double variance;
00205     double angle;
00206   };
00207 
00208 }
00209 
00210 #include "ltiOgdKernels_template.h"
00211 
00212 #endif

Generated on Sat Apr 10 15:25:55 2010 for LTI-Lib by Doxygen 1.6.1