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

ltiGeometricFeatureGroup.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 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  * project ....: LTI Digital Image/Signal Processing Library
00025  * file .......: ltiGeometricFeatureGroup.h
00026  * authors ....: Claudia Goenner
00027  * organization: LTI, RWTH Aachen
00028  * creation ...: 22.07.2003
00029  * revisions ..: $Id: ltiGeometricFeatureGroup.h,v 1.5 2006/02/07 18:58:44 ltilib Exp $
00030  */
00031 
00032 #ifndef LTI_GeometricFeatureGroup_H
00033 #define LTI_GeometricFeatureGroup_H
00034 
00035 //#include <iostream>
00036 #include "ltiIoObject.h"
00037 //#include "ltiIoHandler.h"
00038 #include "ltiConfig.h"
00039 #include "ltiRectangle.h"
00040 
00041 /**
00042  * @file ltiGeometricFeatureGroup.h
00043  *
00044  * This file contains the definitions of the geometric feature types
00045  * used in the LTI-Lib to describe objects by their geometric features.
00046  */
00047 
00048 namespace lti {
00049 
00050   /**
00051    * Description of the simpliest geometric features given by the rectangle
00052    * surrounding the object, the object's area and the center of gravity.
00053    *
00054    * Other geometric feature classes can be derived.
00055    *
00056    * @ingroup gGeomData
00057    */
00058   class geometricFeatureGroup0 : public ioObject {
00059   public:
00060     /**
00061      * default constructor
00062      */
00063     geometricFeatureGroup0();
00064 
00065     /**
00066      * constructor
00067      */
00068     geometricFeatureGroup0(const point& initMinX, const point& initMaxX,
00069          const point& initMinY, const point& initMaxY,
00070          const int initArea, 
00071          const tpoint<float>& initCog);
00072 
00073     /**
00074      * copy constructor
00075      */
00076     geometricFeatureGroup0(const geometricFeatureGroup0& other);
00077 
00078     /**
00079      * @name Duplication
00080      */
00081     //@{
00082 
00083     /**
00084      * copy member
00085      */
00086     geometricFeatureGroup0& copy(const geometricFeatureGroup0& other);
00087 
00088     /**
00089      * alias for copy
00090      */
00091     geometricFeatureGroup0& operator=(const geometricFeatureGroup0& other);
00092 
00093     //@}
00094 
00095     /**
00096      * @name Computation of the geometric features.
00097      */
00098     //@{
00099 
00100     /**
00101      * Partially recomputes the geometric feature vector considering the new point.
00102      * This method assumes, that the center of gravity contains the sum of all added
00103      * points' coordinates so far. To compute the center of gravity from the sum you
00104      * must call completeComputation(). Use with care.
00105      */
00106     bool addObjectPoint(int x, int y);
00107 
00108     /**
00109      * Partially recomputes the geometric feature vector considering the new point.
00110      * This method assumes, that the center of gravity contains the sum of all added
00111      * points' coordinates so far. To compute the center of gravity from the sum you
00112      * must call completeComputation(). Use with care. Calls addObjectPoint(int x, int y).
00113      */
00114     bool addObjectPoint(point p);    
00115 
00116     /**
00117      * Completes the computation of the geometric features, i.e. sum attributes
00118      * contain intermediate results during the computation process, which are
00119      * replaced by the proper attributes value on call of this method. Use with care.
00120      */
00121     bool completeComputation();
00122 
00123     /**
00124      * Recomputes the geometric feature vector by adding a second geometric feature
00125      * vector.
00126      * Here both feature vectors are considered complete, i.e. both center of gravities
00127      * are weighted according to their area.
00128      */
00129     bool operator+=(const geometricFeatureGroup0& other);
00130     //@}
00131 
00132     /**
00133      * @name Comparison
00134      */
00135     //@{
00136 
00137     /**
00138      * test for equality
00139      */
00140     bool operator==(const geometricFeatureGroup0& other) const;
00141 
00142     /**
00143      * test for inequality
00144      */
00145     bool operator!=(const geometricFeatureGroup0& other) const;
00146 
00147     /**
00148      * Check whether this feature group is close to the given feature group, i.e.
00149      * if the two circumscribing rectangles overlap if one is extended by the given
00150      * distance.
00151      * @param other the geometric features to be tested with
00152      * @param dist  the allowed distance between close rectangles
00153      * @return true if the two feature groups are close
00154      */
00155     bool isClose(const geometricFeatureGroup0& other, const point& dist) const;
00156 
00157     //@}
00158 
00159     /**
00160      * @name Input and Output
00161      */
00162     //@{
00163     /**
00164      * read the geometricFeatureGroup from the given ioHandler.
00165      * The complete flag indicates
00166      * if the enclosing begin and end should be also be readed
00167      */
00168     bool  read(ioHandler& handler,
00169          const bool complete = true);
00170     
00171     /**
00172      * write the geometricFeatureGroup0 in the given ioHandler.
00173      * The complete flag indicates
00174      * if the enclosing begin and end should be also be written or not
00175      */
00176     bool write(ioHandler& handler,
00177          const bool complete = true);    
00178     //@}
00179 
00180     /**
00181      * the point on the object's contour with the smallest x-coordinate
00182      */
00183     point minX;
00184 
00185     /**
00186      * the point on the object's contour with the biggest x-coordinate
00187      */
00188     point maxX;   
00189 
00190     /**
00191      * the point on the object's contour with the smallest y-coordinate
00192      */
00193     point minY;
00194 
00195     /**
00196      * the point on the object's contour with the biggest y-coordinate
00197      */
00198     point maxY;     
00199 
00200     /**
00201      * number of pixels covered by the object
00202      */
00203     int area;
00204 
00205     /**
00206      * center of gravity
00207      */
00208     tpoint<float> cog;
00209 
00210   };
00211 
00212 }
00213 
00214 namespace std {
00215 
00216   inline ostream& operator<<(ostream& s, const lti::geometricFeatureGroup0& p) {
00217     s << "(" <<  p.minX << ", " <<  p.maxX
00218       << ", " <<  p.minY << ", " <<  p.maxY
00219       << p.area << ", " << p.cog << ")";
00220     return s;
00221   };
00222 
00223   inline istream& operator>>(istream& s,lti::geometricFeatureGroup0& p) {
00224     char c;
00225     s >> c
00226       >> p.minX >> c
00227       >> p.maxX >> c
00228       >> p.minY >> c
00229       >> p.maxY >> c
00230       >> p.area >> c
00231       >> p.cog >> c;
00232 
00233     return s;
00234   };
00235 }
00236 
00237 #endif

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