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

ltiQmfEnergy.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 .......: ltiQmfEnergy.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 17.5.2001
00030  * revisions ..: $Id: ltiQmfEnergy.h,v 1.10 2006/02/08 11:42:12 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_QMF_ENERGY_H_
00034 #define _LTI_QMF_ENERGY_H_
00035 
00036 #include "ltiImage.h"
00037 #include "ltiVector.h"
00038 #include "ltiQmf.h"
00039 #include "ltiQmfKernels.h"
00040 #include "ltiHistograming1D.h"
00041 #include "ltiGlobalFeatureExtractor.h"
00042 #include <vector>
00043 
00044 namespace lti {
00045   /**
00046    * The qmfEnergy is a functor for extraction of texture features.
00047    * As described in Alvarado et. al. "Axon2 - A visual object recognition
00048    * system for non-rigid objects" SPPAM 2001.
00049    *
00050    * The channel will be separated using a QMF-Bank in several frecuency
00051    * channels.  After that the "energy" is calculated by applying the square
00052    * function to each pixel.  The resulting energy subchannels can be filtered
00053    * using the so called "powerFilter".  All channels are merged by upsampling
00054    * the "smaller" resolutions or alternativelly by downsampling the higher
00055    * resolutions.
00056    *
00057    * The resulting images can be convolved with a gaussian kernel.  The last
00058    * optional step for the qmfEnergy is to apply the square root to each pixel.
00059    *
00060    * From the resulting image an histogram can be generated.
00061    */
00062   class qmfEnergy : public globalFeatureExtractor {
00063   public:
00064     /**
00065      * the parameters for the class qmfEnergy
00066      */
00067     class parameters : public globalFeatureExtractor::parameters {
00068     public:
00069       /**
00070        * default constructor
00071        */
00072       parameters();
00073 
00074       /**
00075        * copy constructor
00076        * @param other the parameters object to be copied
00077        */
00078       parameters(const parameters& other);
00079 
00080       /**
00081        * destructor
00082        */
00083       ~parameters();
00084 
00085       /**
00086        * returns name of this type
00087        */
00088       const char* getTypeName() const;
00089 
00090       /**
00091        * copy the contents of a parameters object
00092        * @param other the parameters object to be copied
00093        * @return a reference to this parameters object
00094        */
00095       parameters& copy(const parameters& other);
00096 
00097       /**
00098        * copy the contents of a parameters object
00099        * @param other the parameters object to be copied
00100        * @return a reference to this parameters object
00101        */
00102       parameters& operator=(const parameters& other);
00103 
00104       /**
00105        * returns a pointer to a clone of the parameters
00106        */
00107       virtual functor::parameters* clone() const;
00108 
00109       /**
00110        * write the parameters in the given ioHandler
00111        * @param handler the ioHandler to be used
00112        * @param complete if true (the default) the enclosing begin/end will
00113        *        be also written, otherwise only the data block will be written.
00114        * @return true if write was successful
00115        */
00116       virtual bool write(ioHandler& handler,const bool complete=true) const;
00117 
00118       /**
00119        * write the parameters in the given ioHandler
00120        * @param handler the ioHandler to be used
00121        * @param complete if true (the default) the enclosing begin/end will
00122        *        be also written, otherwise only the data block will be written.
00123        * @return true if write was successful
00124        */
00125       virtual bool read(ioHandler& handler,const bool complete=true);
00126 
00127 #     ifdef _LTI_MSC_6
00128       /**
00129        * this function is required by MSVC only, as a workaround for a
00130        * very awful bug, which exists since MSVC V.4.0, and still by
00131        * V.6.0 with all bugfixes (so called "service packs") remains
00132        * there...  This method is also public due to another bug, so please
00133        * NEVER EVER call this method directly: use read() instead
00134        */
00135       bool readMS(ioHandler& handler,const bool complete=true);
00136 
00137       /**
00138        * this function is required by MSVC only, as a workaround for a
00139        * very awful bug, which exists since MSVC V.4.0, and still by
00140        * V.6.0 with all bugfixes (so called "service packs") remains
00141        * there...  This method is also public due to another bug, so please
00142        * NEVER EVER call this method directly: use write() instead
00143        */
00144       bool writeMS(ioHandler& handler,const bool complete=true) const;
00145 #     endif
00146 
00147       // ------------------------------------------------
00148       // the parameters
00149       // ------------------------------------------------
00150 
00151       /**
00152        * If true, the square root will be calculated for each pixel (or texel)
00153        * of the resulting fusion of subchannels.
00154        * Default: true
00155        */
00156       bool squareRootEnergy;
00157 
00158       /**
00159        * if true, the "small" channels will be upsampled to use the
00160        * higher resolutions in the energy image.  If false the higher
00161        * resolutions will be downsampled to fit the smallest one.
00162        * Default: false
00163        */
00164       bool upsample;
00165 
00166       /**
00167        * Size for the gaussian kernel used to smooth each partial frequency
00168        * channel.  You can disable the use of this filter setting its size
00169        * to 1.
00170        * Default: 3
00171        */
00172       int powerFilterSize;
00173 
00174       /**
00175        * Variance for the power filter used to smooth each partial frequency
00176        * channel.
00177        * Default: -1 (default gaussian variance)
00178        */
00179       double powerFilterVariance;
00180 
00181       /**
00182        */
00183       double fusionFilterVariance;
00184 
00185       /**
00186        * Size for the gaussian kernel used to smooth the result of merging
00187        * all feature channels. You can disable the use of this filter setting
00188        * its size to 1.
00189        *
00190        * Default: 3
00191        */
00192       int fusionFilterSize;
00193 
00194       /**
00195        * Parameters for the qmf channel transformed applied.
00196        * You will give here the number of levels you want to considered.
00197        * Please note that the given number of levels include the low-frecuency
00198        * band, which is ignored for the energy image computation.  So if
00199        * you give the value "n" for the levels, only "n-1" bands will be
00200        * considered.
00201        * Default value: see lti::qmf::parameters
00202        */
00203       qmf::parameters qmfParam;
00204 
00205       /**
00206        * Parameters for the histogram of energy elements
00207        * Default value:
00208        *  - histogram.cells = 32;
00209        *  - histogram.smooth = false;
00210        *  - histogram.kernel = gaussian kernel of size 3
00211        *  - histogram.mode = Interval
00212        *  - histogram.intervalLow = 0;
00213        *  - histogram.intervalHigh = 0.3;
00214        *  - histogram.ignoreValue = 0;
00215        *  - histogram.normalize = true;
00216        */
00217       histograming1D::parameters histogramParam;
00218     };
00219 
00220     /**
00221      * default constructor
00222      */
00223     qmfEnergy();
00224 
00225     /**
00226      * Constructor with parameters
00227      */
00228     qmfEnergy(const parameters& param);
00229 
00230     /**
00231      * copy constructor
00232      * @param other the object to be copied
00233      */
00234     qmfEnergy(const qmfEnergy& other);
00235 
00236     /**
00237      * destructor
00238      */
00239     virtual ~qmfEnergy();
00240 
00241     /**
00242      * returns the name of this type ("qmfEnergy")
00243      */
00244     virtual const char* getTypeName() const;
00245 
00246     /**
00247      * extract histogram of energy image for each color channel of the
00248      * given image.
00249      * @param src image with the source data.
00250      * @param feature the feature vector generated by the concatenation of
00251      *        the feature vector for each separated color channel RGB.
00252      * @return true if apply successful or false otherwise.
00253      */
00254     bool apply(const image& src,dvector& feature) const;
00255 
00256     /**
00257      * generate the energy image of the given channel
00258      * operates on the given %parameter.
00259      * @param srcdest channel with the source data.  The resulting energy image
00260      *                 will be left here too.
00261      * @return true if apply successful or false otherwise.
00262      */
00263     bool apply(channel& srcdest) const;
00264 
00265     /**
00266      * generate the energy image of the given channel
00267      * operates on a copy of the given %parameters.
00268      * @param src channel with the source data.
00269      * @param dest channel where the resulting energy image be left.
00270      * @return true if apply successful or false otherwise.
00271      */
00272     bool apply(const channel& src,channel& dest) const;
00273 
00274     /**
00275      * extract the histogram of the energy image calculated from the given
00276      * channel.
00277      * operates on a copy of the given %parameters.
00278      * @param src channel with the source data.
00279      * @param dest feature vector generated as a histogram of the
00280      *             energy image
00281      * @return true if apply successful or false otherwise.
00282      */
00283     bool apply(const channel& src,dvector& dest) const;
00284 
00285     /**
00286      * copy data of "other" functor.
00287      * @param other the functor to be copied
00288      * @return a reference to this functor object
00289      */
00290     qmfEnergy& copy(const qmfEnergy& other);
00291 
00292     /**
00293      * returns a pointer to a clone of this functor.
00294      */
00295     virtual functor* clone() const;
00296 
00297     /**
00298      * returns used parameters
00299      */
00300     const parameters& getParameters() const;
00301 
00302   protected:
00303     /**
00304      * get a channel for each band in the wavelet transform of the channel
00305      */
00306     void getChannels(const channel& chnl,
00307                      std::vector<channel>& chnls) const;
00308 
00309     /**
00310      * pad the source channel to have the proper dimensions
00311      */
00312     void padChannel(const int& levels,
00313                     const channel& chnl,
00314                     channel& padchnl) const;
00315   };
00316 }
00317 
00318 #endif

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