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

ltiOgdFilter.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 .......: ltiOgdFilter.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 25.5.2000
00030  * revisions ..: $Id: ltiOgdFilter.h,v 1.10 2006/02/08 11:33:34 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_OGD_FILTER_H_
00034 #define _LTI_OGD_FILTER_H_
00035 
00036 #include "ltiOgdKernels.h"
00037 #include "ltiFilter.h"
00038 #include "ltiConvolution.h"
00039 
00040 namespace lti {
00041   /**
00042    * oriented gaussian derivatives steerable filters
00043    *
00044    * This functions make use of the ogd kernels (lti::ogd1Kernel and
00045    * lti::ogd2Kernel).
00046    *
00047    * If you need to calculate more than one image for different directions,
00048    * use the generateBasis and useBasis members.
00049    *
00050    * If you want to calculate just one image, use the apply members.
00051    */
00052   class ogdFilter : public filter {
00053   public:
00054     /**
00055      * the parameters for all ogd filters
00056      */
00057     class parameters : public filter::parameters {
00058     public:
00059       /**
00060        * default constructor
00061        */
00062       parameters();
00063 
00064       /**
00065        * copy constructor
00066        * @param other the parameters object to be copied
00067        */
00068       parameters(const parameters& other);
00069 
00070       /**
00071        * destructor
00072        */
00073       ~parameters();
00074 
00075       /**
00076        * returns name of this type
00077        */
00078       const char* getTypeName() const;
00079 
00080       /**
00081        * copy the contents of a parameters object
00082        * @param other the parameters object to be copied
00083        * @return a reference to this parameters object
00084        */
00085       parameters& copy(const parameters& other);
00086 
00087       /**
00088        * copy the contents of a parameters object
00089        * @param other the parameters object to be copied
00090        * @return a reference to this parameters object
00091        */
00092       parameters& operator=(const parameters& other);
00093 
00094       /**
00095        * returns a pointer to a clone of the parameters
00096        */
00097       virtual functor::parameters* clone() const;
00098 
00099       /**
00100        * write the parameters in 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 write(ioHandler& handler,const bool complete=true) const;
00107 
00108       /**
00109        * write the parameters in the given ioHandler
00110        * @param handler the ioHandler to be used
00111        * @param complete if true (the default) the enclosing begin/end will
00112        *        be also written, otherwise only the data block will be written.
00113        * @return true if write was successful
00114        */
00115       virtual bool read(ioHandler& handler,const bool complete=true);
00116 
00117 #     ifdef _LTI_MSC_6
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: use read() instead!
00124        */
00125       bool readMS(ioHandler& handler,const bool complete=true);
00126 
00127       /**
00128        * this function is required by MSVC only, as a workaround for a
00129        * very awful bug, which exists since MSVC V.4.0, and still by
00130        * V.6.0 with all bugfixes (so called "service packs") remains
00131        * there...  This method is public due to another bug, so please
00132        * NEVER EVER call this method directly: use write() instead!
00133        */
00134       bool writeMS(ioHandler& handler,const bool complete=true) const;
00135 #     endif
00136 
00137       /**
00138        * Order of the OGD to be used (1 or 2)
00139        *
00140        * Default value: 1
00141        */
00142       int order;
00143 
00144       /**
00145        * size of the used filter kernel (the 2D kernel has a dimension
00146        * size x size)
00147        *
00148        * Default value: 5
00149        */
00150       int size;
00151 
00152       /**
00153        * Variance of the Gaussian.
00154        *
00155        * If you give -1.0 here, the variance will be computed from the
00156        * given size, exaclty as for the Gaussian Kernels.
00157        *
00158        * Default value: 1.4
00159        */
00160       double variance;
00161 
00162       /**
00163        * orientation in radians (0 rad is equivalent to the positive
00164        * x-Axis)
00165        *
00166        * Default value: 0.0
00167        */
00168       double angle;
00169     };
00170 
00171     static const double useAngleOfParameters;
00172 
00173     /**
00174      * default constructor
00175      */
00176     ogdFilter();
00177 
00178     /**
00179      * default constructor with parameters
00180      */
00181     ogdFilter(const parameters& par);
00182 
00183     /** 
00184      * copy constructor
00185      * @param other the object to be copied
00186      */
00187     ogdFilter(const ogdFilter& other);
00188 
00189     /**
00190      * destructor
00191      */
00192     virtual ~ogdFilter();
00193 
00194     /**
00195      * returns the name of this type ("ogdFilter")
00196      */
00197     virtual const char* getTypeName() const;
00198 
00199     /**
00200      * operates on the given parameter.
00201      * @param srcdest channel with the source data.  The result
00202      *                will be left here too.
00203      * @result true if ok, false otherwise.
00204      */
00205     bool apply(channel& srcdest) const;
00206 
00207     /** 
00208      * operates on a copy of the given parameters.
00209      * @param src channel with the source data.
00210      * @param dest channel where the result will be left.
00211      * @result true if ok, false otherwise.
00212      */
00213     bool apply(const channel& src,channel& dest) const;
00214 
00215     /** 
00216      * first order ogd derivative combination.
00217      *
00218      * If the basis channels are known (i.e. the original channel
00219      * convolved with the two basis kernels), you can use this function
00220      * to generate the oriented image in a very efficient manner.  You
00221      * can generate the basis channels with the generateBasisOGD1() member
00222      * function or you can generate them by yourself using the
00223      * lti::ogd1Kernel.
00224      *
00225      * The interpolation functions are cosine for the basis0 and sinus for
00226      * the basis1.
00227      *
00228      * @param basis0 the first basis channel
00229      * @param basis1 the second basis channel
00230      * @param dest   the filtered image
00231      * @param angle  the used direction (in radians).
00232      *               this value must be between -2000 Pi and +2000 Pi.
00233      *               If not given, the angle member of the parameters will
00234      *               be used!
00235      * @return true if ok, false otherwise.
00236      */
00237     bool useBasisOgd1(const channel& basis0,
00238                           const channel& basis1,
00239                                 channel& dest,
00240                           const double& angle = useAngleOfParameters);
00241 
00242     /** 
00243      * generate the basis channels of the first order OGD
00244      * @param src the source channel
00245      * @param basis0 the source channel convolved with the first basis
00246      *               kernel
00247      * @param basis1 the source channel convolved with the second basis
00248      *               kernel.
00249      */
00250     void generateBasisOgd1(const channel& src,
00251                                  channel& basis0,
00252                                  channel& basis1);
00253 
00254     /**
00255      * second order ogd derivative combination
00256      *
00257      * If the basis channels are known (i.e. the original channel
00258      * convolved with the three basis kernels), you can use this function
00259      * to generate the oriented image in a very efficient manner.  You
00260      * can generate the basis channels with the generateBasisOgd2() member
00261      * function or you can generate them by yourself using the
00262      * lti::ogd1Kernel.
00263      *
00264      * The interpolation functions are cos^2 for the basis0, sin^2 for
00265      * the basis1 and 2*cos*sin for the basis2.
00266      *
00267      * @param basis0 the first basis channel
00268      * @param basis1 the second basis channel
00269      * @param basis2 the third basis channel
00270      * @param dest   the filtered image
00271      * @param angle  the direction to be used
00272      */
00273     channel& useBasisOgd2(const channel& basis0,
00274                           const channel& basis1,
00275                           const channel& basis2,
00276                                 channel& dest,
00277                           const double&  angle = useAngleOfParameters);
00278 
00279     /**
00280      * generate the basis channels of the second order Ogd
00281      * @param src the source channel
00282      * @param basis0 the source channel convolved with the first basis
00283      *               kernel
00284      * @param basis1 the source channel convolved with the second basis
00285      *               kernel.
00286      * @param basis2 the source channel convolved with the third basis
00287      *               kernel.
00288      */
00289     void generateBasisOgd2(const channel& src,
00290                                  channel& basis0,
00291                                  channel& basis1,
00292                                  channel& basis2);
00293 
00294     /** 
00295      * copy data of "other" functor.
00296      * @param other the functor to be copied
00297      * @return a reference to this functor object
00298      */
00299     ogdFilter& copy(const ogdFilter& other);
00300 
00301     /**
00302      * returns a pointer to a clone of this functor.
00303      */
00304     virtual functor* clone() const;
00305 
00306     /**
00307      * returns used parameters
00308      */
00309     const parameters& getParameters() const;
00310 
00311   };
00312 
00313 }
00314 
00315 #endif

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