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

ltiExpandVector.h

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 .......: ltiExpandVector.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 22.3.2001
00030  * revisions ..: $Id: ltiExpandVector.h,v 1.8 2006/02/08 11:03:51 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_EXPAND_VECTOR_H_
00034 #define _LTI_EXPAND_VECTOR_H_
00035 
00036 #include "ltiFunctor.h"
00037 #include "ltiVector.h"
00038 
00039 namespace lti {
00040   /**
00041    * This class is used to map a function f(x) represented by a vector
00042    * into another scale f(g(x)), where g(x) can be given.  g(x) must
00043    * be monotonically increasing.
00044    * Linear interpolation will be used between the "samples".
00045    */
00046   class expandVector : public functor {
00047   public:
00048     /**
00049      * the parameters for the class expandVector
00050      */
00051     class parameters : public functor::parameters {
00052     public:
00053       /**
00054        * default constructor
00055        */
00056       parameters();
00057 
00058       /**
00059        * copy constructor
00060        * @param other the parameters object to be copied
00061        */
00062       parameters(const parameters& other);
00063 
00064       /**
00065        * destructor
00066        */
00067       ~parameters();
00068 
00069       /**
00070        * returns name of this type
00071        */
00072       const char* getTypeName() const;
00073 
00074       /**
00075        * copy the contents of a parameters object
00076        * @param other the parameters object to be copied
00077        * @return a reference to this parameters object
00078        */
00079       parameters& copy(const parameters& other);
00080 
00081       /**
00082        * copy the contents of a parameters object
00083        * @param other the parameters object to be copied
00084        * @return a reference to this parameters object
00085        */
00086       parameters& operator=(const parameters& other);
00087 
00088 
00089       /**
00090        * returns a pointer to a clone of the parameters
00091        */
00092       virtual functor::parameters* clone() const;
00093 
00094       /**
00095        * write the parameters in the given ioHandler
00096        * @param handler the ioHandler to be used
00097        * @param complete if true (the default) the enclosing begin/end will
00098        *        be also written, otherwise only the data block will be written.
00099        * @return true if write was successful
00100        */
00101       virtual bool write(ioHandler& handler,const bool complete=true) const;
00102 
00103       /**
00104        * write the parameters in the given ioHandler
00105        * @param handler the ioHandler to be used
00106        * @param complete if true (the default) the enclosing begin/end will
00107        *        be also written, otherwise only the data block will be written.
00108        * @return true if write was successful
00109        */
00110       virtual bool read(ioHandler& handler,const bool complete=true);
00111 
00112 #     ifdef _LTI_MSC_6
00113       /**
00114        * this function is required by MSVC only, as a workaround for a
00115        * very awful bug, which exists since MSVC V.4.0, and still by
00116        * V.6.0 with all bugfixes (so called "service packs") remains
00117        * there...  This method is also public due to another bug, so please
00118        * NEVER EVER call this method directly: use read() instead
00119        */
00120       bool readMS(ioHandler& handler,const bool complete=true);
00121 
00122       /**
00123        * this function is required by MSVC only, as a workaround for a
00124        * very awful bug, which exists since MSVC V.4.0, and still by
00125        * V.6.0 with all bugfixes (so called "service packs") remains
00126        * there...  This method is also public due to another bug, so please
00127        * NEVER EVER call this method directly: use write() instead
00128        */
00129       bool writeMS(ioHandler& handler,const bool complete=true) const;
00130 #     endif
00131 
00132       // ------------------------------------------------
00133       // the parameters
00134       // ------------------------------------------------
00135 
00136       //TODO: comment the parameters of your functor
00137       // If you add more parameters manually, do not forget to do following:
00138       // 1. indicate in the default constructor the default values
00139       // 2. make sure that the copy member also copy your new parameters
00140       // 3. make sure that the read and write members also read and
00141       //    write your parameters
00142 
00143       /**
00144        * This function pointer specifies the coordinate mapping function.
00145        * The default value is \f$g(x)=2^\lfloor x \rfloor -1\f$.
00146        * (see intPow2m())
00147        */
00148       double (*function)(double);
00149     };
00150 
00151     /**
00152      * this function evaluates (2^floor(x))-1
00153      */
00154     static double intPow2m(double x);
00155 
00156     /**
00157      * default constructor.  Initialize with default parameters
00158      */
00159     expandVector();
00160 
00161     /**
00162      * constructor, with the wished default mapping function
00163      */
00164     expandVector(double (*function)(double));
00165 
00166     /**
00167      * copy constructor
00168      * @param other the object to be copied
00169      */
00170     expandVector(const expandVector& other);
00171 
00172     /**
00173      * destructor
00174      */
00175     virtual ~expandVector();
00176 
00177     /**
00178      * returns the name of this type ("expandVector")
00179      */
00180     virtual const char* getTypeName() const;
00181 
00182     /**
00183      * operates on the given %parameter.
00184      * @param srcdest vector<float> with the source data.  The result
00185      *                 will be left here too.
00186      * @result a reference to the <code>srcdest</code>.
00187      */
00188     vector<float>& apply(vector<float>& srcdest) const;
00189 
00190     /**
00191      * operates on the given %parameter.
00192      * @param srcdest vector<double> with the source data.  The result
00193      *                 will be left here too.
00194      * @result a reference to the <code>srcdest</code>.
00195      */
00196     vector<double>& apply(vector<double>& srcdest) const;
00197 
00198     /**
00199      * operates on a copy of the given %parameters.
00200      * @param src vector<float> with the source data.
00201      * @param dest vector<float> where the result will be left.
00202      * @result a reference to the <code>dest</code>.
00203      */
00204     vector<float>& apply(const vector<float>& src,vector<float>& dest) const;
00205 
00206     /**
00207      * operates on a copy of the given %parameters.
00208      * @param src vector<double> with the source data.
00209      * @param dest vector<double> where the result will be left.
00210      * @result a reference to the <code>dest</code>.
00211      */
00212     vector<double>& apply(const vector<double>& src,
00213                           vector<double>& dest) const;
00214 
00215     /**
00216      * short cut for apply and parameters.  This function "draw" the
00217      * input vector on the output vector, using the given function,
00218      * i.e.  out(g(x)) = in(x).  Between the samples g(x) and g(x+1)
00219      * linear interpolation will be used.
00220      * @param in input vector
00221      * @param out output vector
00222      * @param g mapping function
00223      */
00224     vector<double>& draw(const vector<double>& in,
00225                                vector<double>& out,
00226                                double (*g)(double) = intPow2m) const;
00227 
00228     /**
00229      * short cut for apply and parameters.  This function "draw" the
00230      * input vector on the output vector, using the given function,
00231      * i.e.  out(g(x)) = in(x).  Between the samples g(x) and g(x+1)
00232      * linear interpolation will be used.
00233      * @param in input vector
00234      * @param out output vector
00235      * @param g mapping function
00236      */
00237     vector<float>& draw(const vector<float>& in,
00238                                vector<float>& out,
00239                                double (*g)(double) = intPow2m) const;
00240 
00241     /**
00242      * copy data of "other" functor.
00243      * @param other the functor to be copied
00244      * @return a reference to this functor object
00245      */
00246     expandVector& copy(const expandVector& other);
00247 
00248     /**
00249      * returns a pointer to a clone of this functor.
00250      */
00251     virtual functor* clone() const;
00252 
00253     /**
00254      * returns used parameters
00255      */
00256     const parameters& getParameters() const;
00257 
00258   };
00259 }
00260 
00261 #endif

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