latest version v1.9 - last update 10 Apr 2010 |
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 .......: ltiLocationSelector.h 00027 * authors ....: Axel Berner, Xinghan Yu, Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 28.2.2002 00030 * revisions ..: $Id: ltiLocationSelector.h,v 1.8 2006/02/08 11:25:35 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_LOCATION_SELECTOR_H_ 00034 #define _LTI_LOCATION_SELECTOR_H_ 00035 00036 #include "ltiObject.h" 00037 #include <list> 00038 #include <vector> 00039 #include "ltiContour.h" 00040 #include "ltiLocation.h" 00041 #include "ltiFeatureExtractor.h" 00042 00043 namespace lti { 00044 /** 00045 * This functor adjust the given list of locations by a given mask. 00046 * 00047 * There are two modes for this functor. The first one will remove 00048 * all locations of a given list, that are marked to be removed in 00049 * a mask. 00050 * 00051 * The second mode will separate a list of locations into a set of 00052 * smaller lists, so that all locations in each sublist have the 00053 * same label. This way, sublists of locations per object can be 00054 * generated. 00055 */ 00056 class locationSelector : public functor { 00057 public: 00058 /** 00059 * the parameters for the class locationSelector 00060 */ 00061 class parameters : public functor::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 * Defines the "outmask" value for a location in the given mask. 00148 * If the mask is at the position of a location equal to the eraseEntry, 00149 * the location will be removed. 00150 * default: 0 00151 */ 00152 ubyte eraseEntry; 00153 }; 00154 00155 /** 00156 * default constructor 00157 */ 00158 locationSelector(); 00159 00160 /** 00161 * copy constructor 00162 * @param other the object to be copied 00163 */ 00164 locationSelector(const locationSelector& other); 00165 00166 /** 00167 * destructor 00168 */ 00169 virtual ~locationSelector(); 00170 00171 /** 00172 * returns the name of this type ("locationSelector") 00173 */ 00174 virtual const char* getTypeName() const; 00175 00176 /** 00177 * Remove all locations from the given list, for which the corresponding 00178 * entry in the mask have the value getParameters().eraseEntry. 00179 * 00180 * @param mask the decision-mask for the locations 00181 * @param locs location list. If for a location loc in the list holds 00182 * mask.at(loc.position) == getParameters().eraseEntry, then 00183 * the location will be removed from the list. 00184 * 00185 * @return true if apply successful or false otherwise. 00186 */ 00187 bool apply(const channel8& mask, std::list<location>& locs) const; 00188 00189 /** 00190 * Separate the locations list "locs" into several smaller location 00191 * lists, each one having locations for one corresponding label in 00192 * the labeled mask. 00193 * 00194 * @param mask the label mask to select locations. 00195 * @param locs the complete location list. 00196 * @param filteredLocs a vector, indexed by the label number in 00197 * the mask, containing list of locations. 00198 * @return true if apply successful or false otherwise. 00199 */ 00200 bool apply(const matrix<int>& mask, 00201 const std::list<location>& locs, 00202 std::vector< std::list<location> >& filteredLocs) const; 00203 00204 00205 /** 00206 * Separate the locations list "locs" into several smaller locations 00207 * lists, each one having locations for one object in 00208 * the list of areaPoints. 00209 * 00210 * @param objs the list of objects. Each object is represented by 00211 * an areaPoints %object. 00212 * @param locs the complete location list. 00213 * @param filteredLocs a list, with a number of elements equal the 00214 * number of objects in objs plus one, containing list of 00215 * locations, one for each object. The first element of the vector 00216 * will contain all locations assigned to the "background", ie. all 00217 * locations that do not correspond to any object in the objs list. 00218 * @return true if apply successful or false otherwise. 00219 */ 00220 bool apply(const std::list<areaPoints>& objs, 00221 const std::list<location>& locs, 00222 std::vector< std::list<location> >& filteredLocs) const; 00223 00224 /** 00225 * copy data of "other" functor. 00226 * @param other the functor to be copied 00227 * @return a reference to this functor object 00228 */ 00229 locationSelector& copy(const locationSelector& other); 00230 00231 /** 00232 * alias for copy member 00233 * @param other the functor to be copied 00234 * @return a reference to this functor object 00235 */ 00236 locationSelector& operator=(const locationSelector& other); 00237 00238 /** 00239 * returns a pointer to a clone of this functor. 00240 */ 00241 virtual functor* clone() const; 00242 00243 /** 00244 * returns used parameters 00245 */ 00246 const parameters& getParameters() const; 00247 00248 //TODO: comment the attributes of your functor 00249 // If you add more attributes manually, do not forget to do following: 00250 // 1. indicate in the default constructor the default values 00251 // 2. make sure that the copy member also copy your new attributes, or 00252 // to ensure there, that these attributes are properly initialized. 00253 00254 }; 00255 } 00256 00257 #endif