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

ltiSchieleCrowley6DFeature.h

00001 /*
00002  * Copyright (C) 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-Lib: Image Processing and Computer Vision Library
00026  * file .......: ltiSchieleCrowley6DFeature.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 27.3.2002
00030  * revisions ..: $Id: ltiSchieleCrowley6DFeature.h,v 1.9 2006/02/08 11:48:48 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_SCHIELE_CROWLEY6_D_FEATURE_H_
00034 #define _LTI_SCHIELE_CROWLEY6_D_FEATURE_H_
00035 
00036 
00037 #include "ltiObject.h"
00038 
00039 #include <list>
00040 
00041 #include "ltiContour.h"
00042 #include "ltiImage.h"
00043 #include "ltiLocalFeatureExtractor.h"
00044 #include "ltiGlobalFeatureExtractor.h"
00045 #include "ltiLocation.h"
00046 
00047 namespace lti {
00048   /**
00049    * This functor create huge lists of local features, that can be used
00050    * to train the multidimensional receptive field histograms of Schiele
00051    * and Crowley (see lti::shClassifier)
00052    *
00053    * Each vector will be usually 6 dimensional, where the even dimensions will
00054    * correspond to the pixel values of gaussian derivatives in
00055    * x-direction and the odd dimensions will correspond to the y-direction.
00056    *
00057    * Each pair of dimensions will correspond to one resolution or scale, where
00058    * the std. deviation of the gaussians between the levels will be related
00059    * by a factor 2.
00060    *
00061    * More information on the features and classification approach can be
00062    * taken from the original paper:
00063    *
00064    * B. Schiele and J. Crowley.  Recognition without correspondence using
00065    * multidimensional receptive field histograms.  Technical Report No. 453
00066    * MIT Medial Laboratory, Perceptial Computing Section.
00067    */
00068   class schieleCrowley6DFeature : public localFeatureExtractor,
00069                                   public globalFeatureExtractor {
00070   public:
00071     /**
00072      * the parameters for the class schieleCrowley6DFeature
00073      */
00074     class parameters : public localFeatureExtractor::parameters,
00075                        public globalFeatureExtractor::parameters {
00076     public:
00077       /**
00078        * default constructor
00079        */
00080       parameters();
00081 
00082       /**
00083        * copy constructor
00084        * @param other the parameters object to be copied
00085        */
00086       parameters(const parameters& other);
00087 
00088       /**
00089        * destructor
00090        */
00091       ~parameters();
00092 
00093       /**
00094        * returns name of this type
00095        */
00096       const char* getTypeName() const;
00097 
00098       /**
00099        * copy the contents of a parameters object
00100        * @param other the parameters object to be copied
00101        * @return a reference to this parameters object
00102        */
00103       parameters& copy(const parameters& other);
00104 
00105       /**
00106        * copy the contents of a parameters object
00107        * @param other the parameters object to be copied
00108        * @return a reference to this parameters object
00109        */
00110       parameters& operator=(const parameters& other);
00111 
00112 
00113       /**
00114        * returns a pointer to a clone of the parameters
00115        */
00116       virtual functor::parameters* clone() 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 write(ioHandler& handler,const bool complete=true) const;
00126 
00127       /**
00128        * read the parameters from the given ioHandler
00129        * @param handler the ioHandler to be used
00130        * @param complete if true (the default) the enclosing begin/end will
00131        *        be also written, otherwise only the data block will be written.
00132        * @return true if write was successful
00133        */
00134       virtual bool read(ioHandler& handler,const bool complete=true);
00135 
00136 #     ifdef _LTI_MSC_6
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 read() instead
00143        */
00144       bool readMS(ioHandler& handler,const bool complete=true);
00145 
00146       /**
00147        * this function is required by MSVC only, as a workaround for a
00148        * very awful bug, which exists since MSVC V.4.0, and still by
00149        * V.6.0 with all bugfixes (so called "service packs") remains
00150        * there...  This method is also public due to another bug, so please
00151        * NEVER EVER call this method directly: use write() instead
00152        */
00153       bool writeMS(ioHandler& handler,const bool complete=true) const;
00154 #     endif
00155 
00156       // ------------------------------------------------
00157       // the parameters
00158       // ------------------------------------------------
00159 
00160       /**
00161        * Standard deviation for the first resolution
00162        *
00163        * Default value: 2
00164        */
00165       double sigma;
00166 
00167       /**
00168        * Number of resolutions used.  Schiele and Crowley suggest 3
00169        *
00170        * Default value: 3
00171        */
00172       int numResolutions;
00173 
00174     };
00175 
00176     /**
00177      * default constructor
00178      */
00179     schieleCrowley6DFeature();
00180 
00181     /**
00182      * copy constructor
00183      * @param other the object to be copied
00184      */
00185     schieleCrowley6DFeature(const schieleCrowley6DFeature& other);
00186 
00187     /**
00188      * destructor
00189      */
00190     virtual ~schieleCrowley6DFeature();
00191 
00192     /**
00193      * returns the name of this type ("schieleCrowley6DFeature")
00194      */
00195     virtual const char* getTypeName() const;
00196 
00197     /** @name slow apply methods
00198      *
00199      *  Use these methods only when you need the src channel once.  To
00200      *  extract feature for different regions of the same src channel, see
00201      *  for example apply(channel8&,std::list<dvector>&)
00202      */
00203     //@{
00204 
00205     /**
00206      * Get a vector for all non-zero pixels in the mask, using the gaussian
00207      * derivatives of the given channel.
00208      * @param src original channel with the source data
00209      * @param mask only the pixels in src, for which the respective pixel in
00210      *             the mask is different than zero will be considered.
00211      * @param vcts the list of all feature vectors for all masked pixels
00212      *
00213      * @return true if apply successful or false otherwise.
00214      */
00215     bool apply(const channel& src,
00216                const channel8& mask,
00217                std::list<dvector>& vcts) const;
00218 
00219 
00220     /**
00221      * Get a vector for all pixels in the area points.
00222      * @param src original channel with the source data
00223      * @param mask only the pixels in the mask (areaPoints list) will
00224      *             be considered.
00225      * @param vcts the list of all feature vectors for all masked pixels
00226      *
00227      * @return true if apply successful or false otherwise.
00228      */
00229     bool apply(const channel& src,
00230                const areaPoints& mask,
00231                std::list<dvector>& vcts) const;
00232 
00233     /**
00234      * Get a vector for each location in the locations list.
00235      * @param src original channel with the source data
00236      * @param mask only the central pixels in the locations will
00237      *             be considered.
00238      * @param vcts the list of all feature vectors for all masked pixels
00239      *
00240      * @return true if apply successful or false otherwise.
00241      */
00242     bool apply(const channel& src,
00243                const std::list<location>& mask,
00244                std::list<dvector>& vcts) const;
00245 
00246     /**
00247      * Get a vector for each non-zero pixel in the mask.
00248      * @param src original channel with the source data
00249      * @param angle reorient the gaussian derivatives with this angle
00250      * @param mask only the pixels in src, for which the respective pixel in
00251      *             the mask is different than zero will be considered.
00252      * @param vcts the list of all feature vectors for all masked pixels
00253      *
00254      * @return true if apply successful or false otherwise.
00255      */
00256     bool apply(const channel& src,
00257                const double angle,
00258                const channel8& mask,
00259                std::list<dvector>& vcts) const;
00260 
00261     /**
00262      * Get a vector for each pixel in the areaPoint.
00263      * @param src original channel with the source data
00264      * @param angle reorient the gaussian derivatives with this angle
00265      * @param mask only the pixels in the mask (areaPoints list) will
00266      *             be considered.
00267      * @param vcts the list of all feature vectors for all masked pixels
00268      *
00269      * @return true if apply successful or false otherwise.
00270      */
00271     bool apply(const channel& src,
00272                const double angle,
00273                const areaPoints& mask,
00274                std::list<dvector>& vcts) const;
00275 
00276     /**
00277      * Get a vector for each location in the locations list.
00278      * @param src original channel with the source data
00279      * @param angle reorient the gaussian derivatives with this angle
00280      * @param mask only the central pixels of the locations will
00281      *             be considered.
00282      * @param vcts the list of all feature vectors for all masked pixels
00283      *
00284      * @return true if apply successful or false otherwise.
00285      */
00286     bool apply(const channel& src,
00287                const double angle,
00288                const std::list<location>& mask,
00289                std::list<dvector>& vcts) const;
00290 
00291     //@}
00292 
00293     /**
00294      * @name fast apply methods.
00295      *
00296      * All these apply methods use the internal computed gaussian derivatives.
00297      * Before calling these methods you need therefore to specify your channel
00298      * with the method use().
00299      *
00300      * This approach is very fast when extracting different feature sets for
00301      * the same image (for example, feature sets for each object in the image)
00302      *
00303      * In this case you specify once with use() which channel you want to
00304      * use, and after that, you can call the apply method for each
00305      * object found in the image.  This way, the expensive filters will be
00306      * applied just one, and the feature extraction is faster.
00307      */
00308     //@{
00309 
00310     /**
00311      * indicates the channel to be used.  This will allow a pre-computation
00312      * of the gaussian derivatives, that allow a faster analysis of image
00313      * regions.
00314      */
00315     bool use(const channel& chnl);
00316 
00317     /**
00318      * Before calling this method, you need to specify your channel with
00319      * use(const channel&)
00320      * @param mask only the pixels in src, for which the respective pixel in
00321      *             the mask is different than zero will be considered.
00322      * @param vcts the list of all feature vectors for all masked pixels
00323      *
00324      * @return true if apply successful or false otherwise.
00325      */
00326     bool apply(const channel8& mask,
00327                std::list<dvector>& vcts) const;
00328 
00329     /**
00330      * Before calling this method, you need to specify your channel with
00331      * use(const channel&)
00332      * @param mask only the pixels in the mask (areaPoints list) will
00333      *             be considered.
00334      * @param vcts the list of all feature vectors for all masked pixels
00335      *
00336      * @return true if apply successful or false otherwise.
00337      */
00338     bool apply(const areaPoints& mask,
00339                std::list<dvector>& vcts) const;
00340 
00341     /**
00342      * Before calling this method, you need to specify your channel with
00343      * use(const channel&)
00344      * @param mask only the central pixels in the locations will
00345      *             be considered.
00346      * @param vcts the list of all feature vectors for all masked pixels
00347      *
00348      * @return true if apply successful or false otherwise.
00349      */
00350     bool apply(const std::list<location>& mask,
00351                std::list<dvector>& vcts) const;
00352 
00353     /**
00354      * Before calling this method, you need to specify your channel with
00355      * use(const channel&)
00356      * @param angle reorient the gaussian derivatives with this angle
00357      * @param mask only the pixels in src, for which the respective pixel in
00358      *             the mask is different than zero will be considered.
00359      * @param vcts the list of all feature vectors for all masked pixels
00360      *
00361      * @return true if apply successful or false otherwise.
00362      */
00363     bool apply(const double angle,
00364                const channel8& mask,
00365                std::list<dvector>& vcts) const;
00366 
00367     /**
00368      * Before calling this method, you need to specify your channel with
00369      * use(const channel&)
00370      * @param angle reorient the gaussian derivatives with this angle
00371      * @param mask only the pixels in the mask (areaPoints list) will
00372      *             be considered.
00373      * @param vcts the list of all feature vectors for all masked pixels
00374      *
00375      * @return true if apply successful or false otherwise.
00376      */
00377     bool apply(const double angle,
00378                const areaPoints& mask,
00379                std::list<dvector>& vcts) const;
00380 
00381     /**
00382      * Before calling this method, you need to specify your channel with
00383      * use(const channel&)
00384      * @param angle reorient the gaussian derivatives with this angle
00385      * @param mask only the central pixels of the locations will
00386      *             be considered.
00387      * @param vcts the list of all feature vectors for all masked pixels
00388      *
00389      * @return true if apply successful or false otherwise.
00390      */
00391     bool apply(const double angle,
00392                const std::list<location>& mask,
00393                std::list<dvector>& vcts) const;
00394 
00395     //@}
00396 
00397     /**
00398      * copy data of "other" functor.
00399      * @param other the functor to be copied
00400      * @return a reference to this functor object
00401      */
00402     schieleCrowley6DFeature& copy(const schieleCrowley6DFeature& other);
00403 
00404     /**
00405      * alias for copy member
00406      * @param other the functor to be copied
00407      * @return a reference to this functor object
00408      */
00409     schieleCrowley6DFeature& operator=(const schieleCrowley6DFeature& other);
00410 
00411     /**
00412      * returns a pointer to a clone of this functor.
00413      */
00414     virtual functor* clone() const;
00415 
00416     /**
00417      * returns used parameters
00418      */
00419     const parameters& getParameters() const;
00420 
00421   protected:
00422     /**
00423      * get the basis channels for the channel chnl, assuming a
00424      * gaussian with std. deviation sigma.
00425      */
00426     void getBasisChannels(const channel& chnl,
00427                           const double sigma,
00428                           channel& Dx,
00429                           channel& Dy) const;
00430 
00431     /**
00432      * the set of channels internally used.
00433      */
00434     channel* chnls;
00435 
00436   };
00437 }
00438 
00439 #endif

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