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

ltiLocalFeatureExtractor.h

00001 /*
00002  * Copyright (C) 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 .......: ltiLocalFeatureExtractor.h
00027  * authors ....: Arnd Hannemann
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 5.4.2004
00030  * revisions ..: $Id: ltiLocalFeatureExtractor.h,v 1.7 2006/02/08 11:24:15 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_LOCAL_FEATURE_EXTRACTOR_H_
00034 #define _LTI_LOCAL_FEATURE_EXTRACTOR_H_
00035 
00036 //TODO: include only those files which are needed in this header!!
00037 
00038 #include <list>
00039 
00040 #include "ltiImage.h"
00041 #include "ltiLocation.h"
00042 #include "ltiFeatureExtractor.h"
00043 #include "ltiArray.h"
00044 #include "ltiBilinearInterpolator.h"
00045 
00046 namespace lti {
00047   /**
00048    * The local feature extractors
00049    * are functors which extract information from the given images or channels
00050    * at the given locations. This class is parent class for all implemented
00051    * localfeature extractors.
00052    */
00053   class localFeatureExtractor : virtual public featureExtractor {
00054   public:
00055     /**
00056      * The parameters for the class localFeatureExtractor
00057      */
00058     class parameters : virtual public featureExtractor::parameters {
00059     public:
00060 
00061       /**
00062        * enumeration of sampling methods
00063        */
00064       enum eSamplingMethod {
00065         FixedRaySampling, /**< Sampling method which uses circles and rays. 
00066                            *  The pixel values at intersections are returned.
00067                            */
00068         FixedGridSampling /**< Sampling method which uses a fixed circular
00069                            * grid.
00070                            */
00071       };
00072 
00073       /**
00074        * Default constructor
00075        */
00076       parameters();
00077 
00078       /**
00079        * Copy constructor
00080        * @param other the parameters object to be copied
00081        */
00082       parameters(const parameters& other);
00083 
00084       /**
00085        * Destructor
00086        */
00087       ~parameters();
00088 
00089       /**
00090        * Returns name of this type
00091        */
00092       const char* getTypeName() const;
00093 
00094       /**
00095        * Copy the contents of a parameters object
00096        * @param other the parameters object to be copied
00097        * @return a reference to this parameters object
00098        */
00099       parameters& copy(const parameters& other);
00100 
00101       /**
00102        * Copy the contents of a parameters object
00103        * @param other the parameters object to be copied
00104        * @return a reference to this parameters object
00105        */
00106       parameters& operator=(const parameters& other);
00107 
00108 
00109       /**
00110        * Returns a pointer to a clone of the parameters
00111        */
00112       virtual functor::parameters* clone() const;
00113 
00114       /**
00115        * Write the parameters in the given ioHandler
00116        * @param handler the ioHandler to be used
00117        * @param complete if true (the default) the enclosing begin/end will
00118        *        be also written, otherwise only the data block will be written.
00119        * @return true if write was successful
00120        */
00121       virtual bool write(ioHandler& handler,const bool complete=true) const;
00122 
00123       /**
00124        * Read the parameters from the given ioHandler
00125        * @param handler the ioHandler to be used
00126        * @param complete if true (the default) the enclosing begin/end will
00127        *        be also written, otherwise only the data block will be written.
00128        * @return true if write was successful
00129        */
00130       virtual bool read(ioHandler& handler,const bool complete=true);
00131 
00132 #     ifdef _LTI_MSC_6
00133       /**
00134        * This function is required by MSVC only, as a workaround for a
00135        * very awful bug, which exists since MSVC V.4.0, and still by
00136        * V.6.0 with all bugfixes (so called "service packs") remains
00137        * there...  This method is also public due to another bug, so please
00138        * NEVER EVER call this method directly: use read() instead
00139        */
00140       bool readMS(ioHandler& handler,const bool complete=true);
00141 
00142       /**
00143        * This function is required by MSVC only, as a workaround for a
00144        * very awful bug, which exists since MSVC V.4.0, and still by
00145        * V.6.0 with all bugfixes (so called "service packs") remains
00146        * there...  This method is also public due to another bug, so please
00147        * NEVER EVER call this method directly: use write() instead
00148        */
00149       bool writeMS(ioHandler& handler,const bool complete=true) const;
00150 #     endif
00151 
00152       // ------------------------------------------------
00153       // the parameters
00154       // ------------------------------------------------
00155 
00156       //TODO: comment the parameters of your functor
00157       // If you add more parameters manually, do not forget to do following:
00158       // 1. indicate in the default constructor the default values
00159       // 2. make sure that the copy member also copy your new parameters
00160       // 3. make sure that the read and write members also read and
00161       //    write your parameters
00162       
00163 
00164     };
00165 
00166     /**
00167      * Default constructor
00168      */
00169     localFeatureExtractor();
00170 
00171     /**
00172      * Construct a functor using the given parameters
00173      */
00174     localFeatureExtractor(const parameters& par);
00175 
00176     /**
00177      * Copy constructor
00178      * @param other the object to be copied
00179      */
00180     localFeatureExtractor(const localFeatureExtractor& other);
00181 
00182     /**
00183      * Destructor
00184      */
00185     virtual ~localFeatureExtractor();
00186 
00187     /**
00188      * Returns the name of this type ("localFeatureExtractor")
00189      */
00190     virtual const char* getTypeName() const;
00191 
00192     //TODO: comment your apply methods!
00193     
00194     /**
00195      * Copy data of "other" functor.
00196      * @param other the functor to be copied
00197      * @return a reference to this functor object
00198      */
00199     localFeatureExtractor& copy(const localFeatureExtractor& other);
00200 
00201     /**
00202      * Alias for copy member
00203      * @param other the functor to be copied
00204      * @return a reference to this functor object
00205      */
00206     localFeatureExtractor& operator=(const localFeatureExtractor& other);
00207 
00208     /**
00209      * Returns a pointer to a clone of this functor.
00210      */
00211     virtual functor* clone() const;
00212 
00213     /**
00214      * Returns used parameters
00215      */
00216     const parameters& getParameters() const;
00217 
00218 
00219     // Applies :
00220     /**
00221      * Compute the local feature for each location.
00222      * The standard implementation iterates through the lists and
00223      * invokes apply(channel&,const location,dvector)
00224      * for each location.
00225      *
00226      * @param src original channel to be analyzed.
00227      * @param locs locations that need to be analyzed.
00228      * @param dest list of feature vectors.  
00229      * @return true if successful, or false otherwise.  
00230      */
00231     virtual bool apply(const lti::channel& src,
00232                        const std::list<location>& locs,
00233                        std::list<dvector>& dest) const;
00234 
00235     /**
00236      * Compute the local feature for each location.
00237      * The stanard implementation casts the channel8 to a channel
00238      * and invokes the apply for channel.
00239      *
00240      * @param src original channel8 to be analyzed.
00241      * @param locs locations that need to be analyzed.
00242      * @param dest list of feature vectors.  
00243      * @return true if successful, or false otherwise.  
00244      */
00245     virtual bool apply(const lti::channel8& src,
00246                        const std::list<location>& locs,
00247                        std::list<dvector>& dest) const;
00248     /**
00249      * Compute the local feature for each location.
00250      * Not implemented.
00251      *
00252      * @param src list of channels be analyzed.
00253      * @param locs locations that need to be analyzed.
00254      * @param dest list of feature vectors.  
00255      * @return true if successful, or false otherwise.  
00256      */
00257     virtual bool apply(const std::list<channel>& src,
00258                        const std::list<location>& locs,
00259                        std::list<dvector>& dest) const;
00260 
00261     /**
00262      * Compute the local feature for each location.
00263      * The standard implementation iterates through the lists and
00264      * invokes apply(image&,const location,dvector)
00265      * for each location.
00266      *
00267      * @param src original image to be analyzed.
00268      * @param locs locations that need to be analyzed.
00269      * @param dest list of feature vectors.  
00270      * @return true if successful, or false otherwise.  
00271      */
00272     virtual bool apply(const lti::image& src,
00273                        const std::list<location>& locs,
00274                        std::list<dvector>& dest) const;
00275   
00276      /**
00277      * Compute the local feature for the given location.
00278      * The standard implementation splits the image in three
00279      * channels red,green,blue and concatenates the resulting
00280      * vectors of each apply(channel&,const location, devector)
00281      * in this order.
00282      *
00283      * @param src original image to be analyzed.
00284      * @param locs location that need to be analyzed.
00285      * @param dest feature vector. 
00286      * @return true if successful, or false otherwise.  
00287      */
00288     virtual bool apply(const lti::image& src,
00289                        const location& locs,
00290                        dvector& dest) const;
00291 
00292      /**
00293      * Compute the local feature for the given location.
00294      * Not implemented.
00295      *
00296      * @param src original channel to be analyzed.
00297      * @param locs location that need to be analyzed.
00298      * @param dest feature vector. 
00299      * @return true if successful, or false otherwise.  
00300      */
00301     virtual bool apply(const lti::channel& src,
00302                        const location& locs,
00303                        dvector& dest) const;
00304    
00305  
00306   protected:
00307 
00308     /**
00309      * This helper function extracts a sequence of circles around the given
00310      * location. 
00311      * @param chan the input channel
00312      * @param loc the location where extraction should start
00313      * @param dest the output vector
00314      * @param numRays how many points are extracted from each circle
00315      * @param numCircles how many circles are used
00316      * @param scale the radius will be scaled with this factor (Default: 1)
00317      * @param useOrientation whether the angle of the location is used 
00318      * (Default: true)
00319      * @param includeCenter wheter the location itself should be in the
00320      * results (Default: 1)
00321      * @param useCircleOrder wheter the order of the points is along the circles
00322      * or along the rays. The data in the output vector is from 
00323      * the center to the outer and each circle is sampled clockwise. 
00324      * (Default: true)
00325      */
00326     bool fixedRaySampling(const channel& chan, const location& loc, 
00327                           fvector& dest, int numRays,
00328                           int numCircles, float scale = 1.0f,
00329                           bool useOrientation = true,
00330                           bool includeCenter = true,
00331                           bool useCircleOrder = true) const;
00332 
00333 
00334     /**
00335      * This helper function extracts a sequence of circles around the given
00336      * locations. The order of the points in the output vectors is from 
00337      * the center to the outer and each circle is sampled clockwise.
00338      * @param chan the input channel
00339      * @param locs the locations where extraction should start
00340      * @param dests the output vectors
00341      * @param numRays how many points are extracted from each circle
00342      * @param numCircles how many circles are used
00343      * @param scale the radius will be scaled with this factor (Default: 1)
00344      * @param useOrientation whether the angle of the location is used 
00345      * as orientation (Default: true)
00346      * @param includeCenter wheter the location itself should be in the
00347      * results (Default: 1)
00348      * @param useCircleOrder wheter the order of the points is along the 
00349      * circles
00350      * or along the rays. The data in the output vector is from 
00351      * the center to the outer and each circle is sampled clockwise. 
00352      * (Default: true)
00353      */
00354     bool fixedRaySampling(const channel& chan, 
00355                           const std::list<location>& locs, 
00356                           std::list<fvector>& dests, int numRays,
00357                           int numCircles, float scale = 1.0f,
00358                           bool useOrientation = true,
00359                           bool includeCenter = true,
00360                           bool useCircleOrder = true) const;
00361    /**
00362     * This helper function extracts pixels from a given channel. The coordinates
00363     * of this pixels are calculated from the given circPoints. 
00364     * (see initCircle())
00365     * @param chan the input channel
00366     * @param loc the location where extraction should start 
00367     * (center of the circle)
00368     * @param dest the output vector
00369     * @param circPoints mask used to calculate pixel coordinates
00370     * @param scale the radius will be scaled by this factor (Default: 1)
00371     * @param useOrientation whether the angle of the location is used as 
00372     * orientation (Default: true)
00373     */
00374     bool fixedGridSampling(const channel& chan, const location& loc,
00375                            fvector& dest, const array<int>& circPoints,
00376                            float scale = 1.0f,
00377                            bool useOrientation = true) const;
00378 
00379    /**
00380     * This helper function extracts pixels from a given channel. The coordinates
00381     * of this pixels are calculated from the given circPoints. 
00382     * (see initCircle())
00383     * @param chan the input channel
00384     * @param locs the locations where extraction should start 
00385     * (center of the circle)
00386     * @param dests the output vectors
00387     * @param circPoints mask used to calculate pixel coordinates
00388     * @param scale the radius will be scaled by this factor (Default: 1)
00389     * @param useOrientation whether the angle of the location is used as 
00390     * orientation (Default: true)
00391     */
00392     bool fixedGridSampling(const channel& chan, const std::list<location>& locs,
00393                            std::list<fvector>& dests, const array<int>& circPoints,
00394                            float scale = 1.0f,
00395                            bool useOrientation = true) const;
00396 
00397     /** This helper function creates a circular mask with the specified 
00398      * radius to use with fixedGridSampling.
00399      * @param radius which is used for the computed circle
00400      * @param circPoints the resulting mask will be left here
00401      */
00402     bool initCircle(int radius, array<int>& circPoints) const;
00403 
00404    /** 
00405     * Interpolater which can be used in child classes.
00406     */
00407     bilinearInterpolator<float> interpol;
00408 
00409 
00410   };
00411 }
00412 
00413 #endif

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