latest version v1.9 - last update 10 Apr 2010 |
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 /*-------------------------------------------------------------------- 00025 * project ....: LTI-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiLoadVectorImageList.h 00027 * authors ....: Peter Doerfler 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 28.11.2003 00030 * revisions ..: $Id: ltiLoadVectorImageList.h,v 1.6 2006/02/08 12:06:33 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_LOAD_VECTOR_IMAGE_LIST_H_ 00034 #define _LTI_LOAD_VECTOR_IMAGE_LIST_H_ 00035 00036 00037 #include "ltiImage.h" 00038 #include "ltiVector.h" 00039 #include "ltiDownsampling.h" 00040 #include "ltiLoadImageList.h" 00041 00042 namespace lti { 00043 /** 00044 * This functor loads a list of images and transforms each into a 00045 * vector or all into a matrix where each row contains a vector 00046 * image. For convenience it is possible to perform downsampling on 00047 * the images while loading. Note that when getting a matrix of 00048 * vector images all images must have the same size (i.e. all vector 00049 * images must have the same length). 00050 * 00051 * Use this functor just like loadImageList. 00052 */ 00053 class loadVectorImageList : public loadImageList { 00054 public: 00055 /** 00056 * The parameters for the class loadVectorImageList 00057 */ 00058 class parameters : public loadImageList::parameters { 00059 public: 00060 /** 00061 * Default constructor 00062 */ 00063 parameters(); 00064 00065 /** 00066 * Copy constructor 00067 * @param other the parameters object to be copied 00068 */ 00069 parameters(const parameters& other); 00070 00071 /** 00072 * Destructor 00073 */ 00074 ~parameters(); 00075 00076 /** 00077 * Returns name of this type 00078 */ 00079 const char* getTypeName() const; 00080 00081 /** 00082 * Copy the contents of a parameters object 00083 * @param other the parameters object to be copied 00084 * @return a reference to this parameters object 00085 */ 00086 parameters& copy(const parameters& other); 00087 00088 /** 00089 * Copy the contents of a parameters object 00090 * @param other the parameters object to be copied 00091 * @return a reference to this parameters object 00092 */ 00093 parameters& operator=(const parameters& other); 00094 00095 00096 /** 00097 * Returns a pointer to a clone of the parameters 00098 */ 00099 virtual functor::parameters* clone() const; 00100 00101 /** 00102 * Write the parameters in the given ioHandler 00103 * @param handler the ioHandler to be used 00104 * @param complete if true (the default) the enclosing begin/end will 00105 * be also written, otherwise only the data block will be written. 00106 * @return true if write was successful 00107 */ 00108 virtual bool write(ioHandler& handler,const bool complete=true) const; 00109 00110 /** 00111 * Read the parameters from the given ioHandler 00112 * @param handler the ioHandler to be used 00113 * @param complete if true (the default) the enclosing begin/end will 00114 * be also written, otherwise only the data block will be written. 00115 * @return true if write was successful 00116 */ 00117 virtual bool read(ioHandler& handler,const bool complete=true); 00118 00119 # ifdef _LTI_MSC_6 00120 /** 00121 * This function is required by MSVC only, as a workaround for a 00122 * very awful bug, which exists since MSVC V.4.0, and still by 00123 * V.6.0 with all bugfixes (so called "service packs") remains 00124 * there... This method is also public due to another bug, so please 00125 * NEVER EVER call this method directly: use read() instead 00126 */ 00127 bool readMS(ioHandler& handler,const bool complete=true); 00128 00129 /** 00130 * This function is required by MSVC only, as a workaround for a 00131 * very awful bug, which exists since MSVC V.4.0, and still by 00132 * V.6.0 with all bugfixes (so called "service packs") remains 00133 * there... This method is also public due to another bug, so please 00134 * NEVER EVER call this method directly: use write() instead 00135 */ 00136 bool writeMS(ioHandler& handler,const bool complete=true) const; 00137 # endif 00138 00139 // ------------------------------------------------ 00140 // the parameters 00141 // ------------------------------------------------ 00142 00143 //TODO: comment the parameters of your functor 00144 // If you add more parameters manually, do not forget to do following: 00145 // 1. indicate in the default constructor the default values 00146 // 2. make sure that the copy member also copy your new parameters 00147 // 3. make sure that the read and write members also read and 00148 // write your parameters 00149 00150 00151 /** 00152 * If true each image is downsampled as specified in 00153 * downsamplingParam. Default false. 00154 */ 00155 bool downsample; 00156 00157 /** 00158 * Parameters used for downsampling when downsample is \a 00159 * true. Default are the default downsampling::parameters. 00160 */ 00161 downsampling::parameters downsamplingParam; 00162 }; 00163 00164 /** 00165 * Default constructor 00166 */ 00167 loadVectorImageList(); 00168 00169 /** 00170 * Construct a functor using the given parameters 00171 */ 00172 loadVectorImageList(const parameters& par); 00173 00174 /** 00175 * Copy constructor 00176 * @param other the object to be copied 00177 */ 00178 loadVectorImageList(const loadVectorImageList& other); 00179 00180 /** 00181 * Sets one of two \a modes: parameters::ListFileName or 00182 * parameters::DirName and the corresponding \a name of the file 00183 * or directory in the parameters. Default is the filename of a textfile 00184 * containing image filenames. 00185 * 00186 * See also: 00187 * - loadVectorImageList(const std::list<std::string>&), 00188 * - use(const std::string&, parameters::eOperationMode), 00189 * - use(const std::list<std::string>&). 00190 * 00191 * @param name name of a file containing image filenames or of a directory 00192 * @param mode parameters::ListFileName or parameters::DirName. 00193 */ 00194 loadVectorImageList(const std::string& name, 00195 loadImageList::parameters::eOperationMode mode= 00196 loadImageList::parameters::ListFileName); 00197 00198 /** 00199 * Sets parameters::mode to parameters::NameList and uses the list 00200 * \a names for loading the files. 00201 * 00202 * See also: 00203 * - loadImageList(const std::string&, parameters::eOperationMode), 00204 * - use(const std::string&, parameters::eOperationMode), 00205 * - use(const std::list<std::string>&). 00206 * 00207 * @param names list of image filenames. 00208 */ 00209 loadVectorImageList(const std::list<std::string>& names); 00210 00211 /** 00212 * Destructor 00213 */ 00214 virtual ~loadVectorImageList(); 00215 00216 /** 00217 * Returns the name of this type ("loadVectorImageList") 00218 */ 00219 virtual const char* getTypeName() const; 00220 00221 /** 00222 * Returns the current image from the list as a vector. 00223 * @param img the current image as vector 00224 * @return true if apply successful or false otherwise. 00225 */ 00226 bool apply(fvector& img); 00227 00228 /** 00229 * Returns the current image from the list as a vector. 00230 * @param img the current image as vector 00231 * @param rows number of rows of the image 00232 * @param columns number of columns of the image 00233 * @return true if apply successful or false otherwise. 00234 */ 00235 bool apply(fvector& img, int& rows, int& columns); 00236 00237 /** 00238 * Returns the current image from the list as a vector. 00239 * @param img the current image as vector 00240 * @return true if apply successful or false otherwise. 00241 */ 00242 bool apply(dvector& img); 00243 00244 /** 00245 * Returns the current image from the list as a vector. 00246 * @param img the current image as vector 00247 * @param rows number of rows of the image 00248 * @param columns number of columns of the image 00249 * @return true if apply successful or false otherwise. 00250 */ 00251 bool apply(dvector& img, int& rows, int& columns); 00252 00253 /** 00254 * Returns all images from the list as rows of the %matrix \a images. 00255 * @param images all images as rows of the matrix. 00256 * @return true if apply successful or false otherwise. 00257 */ 00258 bool apply(fmatrix& images); 00259 00260 /** 00261 * Returns all images from the list as rows of the %matrix \a images. 00262 * @param images all images as rows of the matrix. 00263 * @param rows number of rows of each image 00264 * @param columns number of columns of each image 00265 * @return true if apply successful or false otherwise. 00266 */ 00267 bool apply(fmatrix& images, int& rows, int& columns); 00268 00269 /** 00270 * Returns all images from the list as rows of the %matrix \a images. 00271 * @param images all images as rows of the matrix. 00272 * @return true if apply successful or false otherwise. 00273 */ 00274 bool apply(dmatrix& images); 00275 00276 /** 00277 * Returns all images from the list as rows of the %matrix \a images. 00278 * @param images all images as rows of the matrix. 00279 * @param rows number of rows of each image 00280 * @param columns number of columns of each image 00281 * @return true if apply successful or false otherwise. 00282 */ 00283 bool apply(dmatrix& images, int& rows, int& columns); 00284 00285 /** 00286 * Copy data of "other" functor. 00287 * @param other the functor to be copied 00288 * @return a reference to this functor object 00289 */ 00290 loadVectorImageList& copy(const loadVectorImageList& other); 00291 00292 /** 00293 * Alias for copy member 00294 * @param other the functor to be copied 00295 * @return a reference to this functor object 00296 */ 00297 loadVectorImageList& operator=(const loadVectorImageList& other); 00298 00299 /** 00300 * Returns a pointer to a clone of this functor. 00301 */ 00302 virtual functor* clone() const; 00303 00304 /** 00305 * Returns used parameters 00306 */ 00307 const parameters& getParameters() const; 00308 00309 /** 00310 * set functor's parameters. 00311 * This member makes a copy of <em>theParam</em>: the functor 00312 * will keep its own copy of the parameters! 00313 * @return true if successful, false otherwise 00314 */ 00315 virtual bool updateParameters(); 00316 00317 /** 00318 * Read the functor from the given ioHandler. 00319 * 00320 * The default implementation is to read just the parameters object. 00321 * 00322 * Since this virtual method needs to know the exact type of the 00323 * parameters to call the proper read method, it will just assume that the 00324 * current functor instance has a valid parameter set. If this is not 00325 * the case, you need to reimplement the read method to set first a dummy 00326 * parameter object. 00327 * 00328 * @param handler the ioHandler to be used 00329 * @param complete if true (the default) the enclosing begin/end will 00330 * be also written, otherwise only the data block will be written. 00331 * @return true if write was successful 00332 */ 00333 virtual bool read(ioHandler& handler,const bool complete=true); 00334 00335 protected: 00336 00337 downsampling down; 00338 00339 }; 00340 } 00341 00342 #endif