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

ltiRegionMerge.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 .......: ltiRegionMerge.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 18.3.2002
00030  * revisions ..: $Id: ltiRegionMerge.h,v 1.8 2006/02/08 11:45:28 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_REGION_MERGE_H_
00034 #define _LTI_REGION_MERGE_H_
00035 
00036 #include "ltiContour.h"
00037 #include "ltiImage.h"
00038 #include "ltiFunctor.h"
00039 
00040 namespace lti {
00041   /**
00042    * This functor uses a similarity matrix (see lti::similarityMatrix) and
00043    * a threshold value given in the parameters to decide if two objects in
00044    * a mask (also returned by lti::similarityMatrix or by lti::objectsFromMask)
00045    * should be merged or not.
00046    *
00047    * The result is a new mask with less objects than the original one.
00048    *
00049    * See also \ref segmPage.
00050    */
00051   class regionMerge : public functor {
00052   public:
00053     /**
00054      * the parameters for the class regionMerge
00055      */
00056     class parameters : public functor::parameters {
00057     public:
00058       /**
00059        * default constructor
00060        */
00061       parameters();
00062 
00063       /**
00064        * copy constructor
00065        * @param other the parameters object to be copied
00066        */
00067       parameters(const parameters& other);
00068 
00069       /**
00070        * destructor
00071        */
00072       ~parameters();
00073 
00074       /**
00075        * returns name of this type
00076        */
00077       const char* getTypeName() const;
00078 
00079       /**
00080        * copy the contents of a parameters object
00081        * @param other the parameters object to be copied
00082        * @return a reference to this parameters object
00083        */
00084       parameters& copy(const parameters& other);
00085 
00086       /**
00087        * copy the contents of a parameters object
00088        * @param other the parameters object to be copied
00089        * @return a reference to this parameters object
00090        */
00091       parameters& operator=(const parameters& other);
00092 
00093 
00094       /**
00095        * returns a pointer to a clone of the parameters
00096        */
00097       virtual functor::parameters* clone() const;
00098 
00099       /**
00100        * write the parameters in the given ioHandler
00101        * @param handler the ioHandler to be used
00102        * @param complete if true (the default) the enclosing begin/end will
00103        *        be also written, otherwise only the data block will be written.
00104        * @return true if write was successful
00105        */
00106       virtual bool write(ioHandler& handler,const bool complete=true) const;
00107 
00108       /**
00109        * read the parameters from the given ioHandler
00110        * @param handler the ioHandler to be used
00111        * @param complete if true (the default) the enclosing begin/end will
00112        *        be also written, otherwise only the data block will be written.
00113        * @return true if write was successful
00114        */
00115       virtual bool read(ioHandler& handler,const bool complete=true);
00116 
00117 #     ifdef _LTI_MSC_6
00118       /**
00119        * this function is required by MSVC only, as a workaround for a
00120        * very awful bug, which exists since MSVC V.4.0, and still by
00121        * V.6.0 with all bugfixes (so called "service packs") remains
00122        * there...  This method is also public due to another bug, so please
00123        * NEVER EVER call this method directly: use read() instead
00124        */
00125       bool readMS(ioHandler& handler,const bool complete=true);
00126 
00127       /**
00128        * this function is required by MSVC only, as a workaround for a
00129        * very awful bug, which exists since MSVC V.4.0, and still by
00130        * V.6.0 with all bugfixes (so called "service packs") remains
00131        * there...  This method is also public due to another bug, so please
00132        * NEVER EVER call this method directly: use write() instead
00133        */
00134       bool writeMS(ioHandler& handler,const bool complete=true) const;
00135 #     endif
00136 
00137       // ------------------------------------------------
00138       // the parameters
00139       // ------------------------------------------------
00140 
00141       /**
00142        * Smallest required similarity in the similarity matrix to
00143        * decide if two regions need to be merged or not.
00144        *
00145        * Default value: 0.001
00146        */
00147       double threshold;
00148 
00149     };
00150 
00151     /**
00152      * default constructor
00153      */
00154     regionMerge();
00155 
00156     /**
00157      * copy constructor
00158      * @param other the object to be copied
00159      */
00160     regionMerge(const regionMerge& other);
00161 
00162     /**
00163      * destructor
00164      */
00165     virtual ~regionMerge();
00166 
00167     /**
00168      * returns the name of this type ("regionMerge")
00169      */
00170     virtual const char* getTypeName() const;
00171 
00172     /**
00173      * operates on a copy of the given %parameters.
00174      * @param srcmask source mask.  Each object must be represented by one
00175      *                              label.
00176      * @param simMat The similarity matrix.  The size of the matrix must
00177      *               be at least equal the number of labels plus one.
00178      * @param destmask resulting mask with merged objects.
00179      * @return true if apply successful or false otherwise.
00180      */
00181     bool apply(const imatrix& srcmask,
00182                const dmatrix& simMat,
00183                imatrix& destmask) const;
00184 
00185     bool apply(const imatrix& srcmask,
00186          const dmatrix& simMat,
00187          const dvector& thresholds,
00188          imatrix& destmask) const;
00189 
00190     /**
00191      * copy data of "other" functor.
00192      * @param other the functor to be copied
00193      * @return a reference to this functor object
00194      */
00195     regionMerge& copy(const regionMerge& other);
00196 
00197     /**
00198      * alias for copy member
00199      * @param other the functor to be copied
00200      * @return a reference to this functor object
00201      */
00202     regionMerge& operator=(const regionMerge& other);
00203 
00204     /**
00205      * returns a pointer to a clone of this functor.
00206      */
00207     virtual functor* clone() const;
00208 
00209     /**
00210      * returns used parameters
00211      */
00212     const parameters& getParameters() const;
00213   };
00214 }
00215 
00216 #endif

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