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

ltiSkinASM.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 Digital Image/Signal Processing Library
00026  * file .......: ltiSkinASM.h
00027  * authors ....: Holger Fillbrandt, Benjamin Winkler
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 1.3.2002
00030  * revisions ..: $Id: ltiSkinASM.h,v 1.8 2006/02/08 11:51:08 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_SKIN_A_S_M_H_
00034 #define _LTI_SKIN_A_S_M_H_
00035 
00036 
00037 #include "ltiGradientASM.h"
00038 
00039 namespace lti {
00040   /**
00041    * This is an alignment strategy for activeShapeModels (ASM), that works on a gradient
00042    * channel and a skin probability channel, to trace skin colored objects.
00043    *
00044    * In addition to the feature selection in the class gradientASM, feature points have
00045    * to be skin colored in the inside region and non-skin colored in the outside region.
00046    * Points are valid, when they only contain skin points on the inside of the shape
00047    * (along the normal, within a distance <= 'parameters::searchExtent').
00048    * If no such points are found, search is continued further inside the shape (see
00049    * parameters::shrinkExtent).
00050    * When too many points are completely surrounded by skin, search for a skin border
00051    * is continued further outside the shape (see parameters::enlargeExtent).
00052    *
00053    * <b>Important note:</b> Due to the inside/outside nature, the points of the shape
00054    * must be given in clockwise order!
00055    */
00056   class skinASM : public gradientASM {
00057   public:
00058     /**
00059      * the parameters for the class skinASM
00060      */
00061     class parameters : public gradientASM::parameters {
00062     public:
00063       /**
00064        * default constructor
00065        */
00066       parameters();
00067 
00068       /**
00069        * copy constructor
00070        * @param other the parameters object to be copied
00071        */
00072       parameters(const parameters& other);
00073 
00074       /**
00075        * destructor
00076        */
00077       ~parameters();
00078 
00079       /**
00080        * returns name of this type
00081        */
00082       const char* getTypeName() const;
00083 
00084       /**
00085        * copy the contents of a parameters object
00086        * @param other the parameters object to be copied
00087        * @return a reference to this parameters object
00088        */
00089       parameters& copy(const parameters& other);
00090 
00091       /**
00092        * copy the contents of a parameters object
00093        * @param other the parameters object to be copied
00094        * @return a reference to this parameters object
00095        */
00096       parameters& operator=(const parameters& other);
00097 
00098 
00099       /**
00100        * returns a pointer to a clone of the parameters
00101        */
00102       virtual functor::parameters* clone() const;
00103 
00104       /**
00105        * write the parameters in the given ioHandler
00106        * @param handler the ioHandler to be used
00107        * @param complete if true (the default) the enclosing begin/end will
00108        *        be also written, otherwise only the data block will be written.
00109        * @return true if write was successful
00110        */
00111       virtual bool write(ioHandler& handler,const bool complete=true) const;
00112 
00113       /**
00114        * read the parameters from the given ioHandler
00115        * @param handler the ioHandler to be used
00116        * @param complete if true (the default) the enclosing begin/end will
00117        *        be also written, otherwise only the data block will be written.
00118        * @return true if write was successful
00119        */
00120       virtual bool read(ioHandler& handler,const bool complete=true);
00121 
00122 #     ifdef _LTI_MSC_6
00123       /**
00124        * this function is required by MSVC only, as a workaround for a
00125        * very awful bug, which exists since MSVC V.4.0, and still by
00126        * V.6.0 with all bugfixes (so called "service packs") remains
00127        * there...  This method is also public due to another bug, so please
00128        * NEVER EVER call this method directly: use read() instead
00129        */
00130       bool readMS(ioHandler& handler,const bool complete=true);
00131 
00132       /**
00133        * this function is required by MSVC only, as a workaround for a
00134        * very awful bug, which exists since MSVC V.4.0, and still by
00135        * V.6.0 with all bugfixes (so called "service packs") remains
00136        * there...  This method is also public due to another bug, so please
00137        * NEVER EVER call this method directly: use write() instead
00138        */
00139       bool writeMS(ioHandler& handler,const bool complete=true) const;
00140 #     endif
00141 
00142       // ------------------------------------------------
00143       // the parameters
00144       // ------------------------------------------------
00145 
00146 
00147       /**
00148        * the outside radius in which skin borders are searched, if too many borderpoints are
00149        * inside a skin-area (must be higher than searchExtent, to produce an effect).
00150        *
00151        * default: 30
00152        */
00153       int enlargeExtent;
00154 
00155       /**
00156        * the inside radius in which skin borders are searched, if no skin is inside search extent
00157        * (must be higher than searchExtent, to produce an effect).
00158        *
00159        * default: 15
00160        */
00161       int shrinkExtent;
00162 
00163       /**
00164        * defines how many points of the border are allowed to lie inside skin regions
00165        * (valid: 0.0...1.0; meaning 0% to 100%)
00166        * if too many points are inside skin regions, the shape is enlarged.
00167        *
00168        * default: 0.7
00169        */
00170       float maxInsideSkin;
00171 
00172       /**
00173        * threshold to decide, if a pixel is skin or not (valid: 0.0...1.0)
00174        *
00175        * default: 0.5
00176        */
00177       float skinThreshold;
00178 
00179       /**
00180        * reliability: only skin borders considered to be reliable
00181        *
00182        * default: true
00183        */
00184       bool onlySkinBordersReliable;
00185     };
00186 
00187     /**
00188      * default constructor
00189      */
00190     skinASM();
00191 
00192     /**
00193      * copy constructor
00194      * @param other the object to be copied
00195      */
00196     skinASM(const skinASM& other);
00197 
00198     /**
00199      * destructor
00200      */
00201     virtual ~skinASM();
00202 
00203     /**
00204      * returns the name of this type ("skinASM")
00205      */
00206     virtual const char* getTypeName() const;
00207 
00208     /**
00209      * copy data of "other" functor.
00210      * @param other the functor to be copied
00211      * @return a reference to this functor object
00212      */
00213     skinASM& copy(const skinASM& other);
00214 
00215     /**
00216      * alias for copy member
00217      * @param other the functor to be copied
00218      * @return a reference to this functor object
00219      */
00220     skinASM& operator=(const skinASM& other);
00221 
00222     /**
00223      * returns a pointer to a clone of this functor.
00224      */
00225     virtual functor* clone() const;
00226 
00227     /**
00228      * returns used parameters
00229      */
00230     const parameters& getParameters() const;
00231 
00232 
00233     /**
00234      * align shape on the given gradient channel.
00235      * iteratively, scan for best border as described above
00236      */
00237     pointDistributionModel::shape& apply(pointDistributionModel::shape& srcdest,
00238                                          const channel &gradientChannel,
00239                                          const channel &skinProbChannel) const;
00240 
00241   protected:
00242 
00243     /**
00244      * iteratively align shape on the given gradient and skin probality channels.
00245      * @return a reference to the <code>srcdest</code>.
00246      */
00247     pointDistributionModel::shape& adjustShape(pointDistributionModel::shape &srcdest,
00248                                                const channel &gradientChannel,
00249                                                const channel &skinProbChannel,
00250                                                fvector &pointReliability) const;
00251 
00252   };
00253 }
00254 
00255 #endif

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