latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 1999, 2000, 2001, 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 .......: ltiModifier.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 16.11.99 00030 * revisions ..: $Id: ltiModifier.h,v 1.9 2006/02/08 11:31:38 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_MODIFIER_H_ 00034 #define _LTI_MODIFIER_H_ 00035 00036 #include "ltiImage.h" 00037 #include "ltiFunctor.h" 00038 #include "ltiBoundaryType.h" 00039 00040 namespace lti { 00041 /** 00042 * Base class for all filters and other functors, which transform an image 00043 * or channel in another image of the same type. 00044 * 00045 * For those functors which generate more than one image or 00046 * transforms the image in another totally different space (like a 00047 * vector), are derived from lti::transform (see for example the FFT 00048 * transformation!) 00049 */ 00050 class modifier : public functor { 00051 public: 00052 /** 00053 * parameter class for modifier 00054 */ 00055 class parameters : public functor::parameters { 00056 public: 00057 00058 /** @name Aliases for lti::eBoundaryType elements 00059 * \deprecated will be deleted in the future. Use lti::eBoundaryType instead 00060 */ 00061 //@{ 00062 00063 /** 00064 * alias for lti::Zero. 00065 * \deprecated will be deleted in the future. Use lti::eBoundaryType instead. 00066 */ 00067 static const eBoundaryType Black; 00068 00069 /** 00070 * alias for lti::Mirror. 00071 * \deprecated will be deleted in the future. Use lti::eBoundaryType instead. 00072 */ 00073 static const eBoundaryType Mirror; 00074 00075 /** 00076 * alias for lti::Periodic. 00077 * \deprecated will be deleted in the future. Use lti::eBoundaryType instead. 00078 */ 00079 static const eBoundaryType Periodic; 00080 00081 /** 00082 * alias for lti::Constant. 00083 * \deprecated will be deleted in the future. Use lti::eBoundaryType instead. 00084 */ 00085 static const eBoundaryType Constant; 00086 00087 /** 00088 * alias for lti::NoBoundary. 00089 * \deprecated will be deleted in the future. Use lti::eBoundaryType instead. 00090 */ 00091 static const eBoundaryType NoBoundary; 00092 //@} 00093 00094 00095 /** 00096 * default constructor 00097 */ 00098 parameters() : functor::parameters(),boundaryType(Zero) {}; 00099 00100 /** 00101 * copy constructor 00102 */ 00103 parameters(const parameters& other) : functor::parameters() { 00104 copy(other); 00105 }; 00106 00107 /** 00108 * returns the name of this type 00109 */ 00110 virtual const char* getTypeName() const; 00111 00112 /** 00113 * copy member 00114 */ 00115 parameters& copy(const parameters& other); 00116 00117 /** 00118 * returns a pointer to a clone of the parameters. 00119 */ 00120 virtual functor::parameters* clone() const; 00121 00122 /** 00123 * write the parameters in the given ioHandler 00124 * @param handler the ioHandler to be used 00125 * @param complete if true (the default) the enclosing begin/end will 00126 * be also written, otherwise only the data block will be written. 00127 * @return true if write was successful 00128 */ 00129 virtual bool write(ioHandler& handler,const bool complete=true) const; 00130 00131 /** 00132 * write the parameters in the given ioHandler 00133 * @param handler the ioHandler to be used 00134 * @param complete if true (the default) the enclosing begin/end will 00135 * be also written, otherwise only the data block will be written. 00136 * @return true if write was successful 00137 */ 00138 virtual bool read(ioHandler& handler,const bool complete=true); 00139 00140 # ifdef _LTI_MSC_6 00141 /** 00142 * this function is required by MSVC only, as a workaround for a 00143 * very awful bug, which exists since MSVC V.4.0, and still by 00144 * V.6.0 with all bugfixes (so called "service packs") remains 00145 * there... This method is public due to another bug, so please 00146 * NEVER EVER call this method directly 00147 */ 00148 bool readMS(ioHandler& handler,const bool complete=true); 00149 00150 /** 00151 * this function is required by MSVC only, as a workaround for a 00152 * very awful bug, which exists since MSVC V.4.0, and still by 00153 * V.6.0 with all bugfixes (so called "service packs") remains 00154 * there... This method is public due to another bug, so please 00155 * NEVER EVER call this method directly! 00156 */ 00157 bool writeMS(ioHandler& handler,const bool complete=true) const; 00158 # endif 00159 00160 // ------------------------------------------------ 00161 // the parameters 00162 // ------------------------------------------------ 00163 00164 /** 00165 * how the boundaries will be used 00166 * 00167 * Default: eBoundaryType::Zero 00168 */ 00169 eBoundaryType boundaryType; 00170 00171 00172 }; 00173 00174 /** 00175 * default constructor 00176 */ 00177 modifier() : functor() {}; 00178 00179 /** 00180 * destructor 00181 */ 00182 virtual ~modifier(); 00183 00184 /** 00185 * returns current parameters. 00186 */ 00187 const parameters& getParameters() const; 00188 00189 /** 00190 * operates on the given parameter (vector of floats). 00191 * 00192 * If this method is not implemented, an exception of type 00193 * lti::functor::invalidMethodException will be thrown. 00194 * 00195 * @param srcdest vector of floats with the source data. The result 00196 * will be left here too. 00197 * @return true if successful, false otherwise. 00198 */ 00199 bool apply(fvector& srcdest) const; 00200 00201 /** 00202 * operates on the given parameter (vector of integers). 00203 * If this method is not implemented, an exception of type 00204 * lti::functor::invalidMethodException will be thrown. 00205 * @param srcdest vector of integers with the source data. The result 00206 * will be left here too. 00207 * @return true if successful, false otherwise. 00208 */ 00209 bool apply(ivector& srcdest) const; 00210 00211 /** 00212 * operates on the given parameter (vector of unsigned bytes). 00213 * If this method is not implemented, an exception of type 00214 * lti::functor::invalidMethodException will be thrown. 00215 * @param srcdest vector of unsigned bytes with the source data. The 00216 * result will be left here too. 00217 * @return true if successful, false otherwise. 00218 */ 00219 virtual bool apply(vector<ubyte>& srcdest) const; 00220 00221 /** 00222 * operates on the given parameter (channel, i.e. matrix of floats). 00223 * If this method is not implemented, an exception of type 00224 * lti::functor::invalidMethodException will be thrown. 00225 * @param srcdest channel with the source data. The result 00226 * will be left here too. 00227 * @return true if successful, false otherwise. 00228 */ 00229 virtual bool apply(matrix<channel::value_type>& srcdest) const; 00230 00231 /** 00232 * operates on the given parameter (channel, i.e. matrix of floats). 00233 * If this method is not implemented, an exception of type 00234 * lti::functor::invalidMethodException will be thrown. 00235 * @param srcdest channel with the source data. The result 00236 * will be left here too. 00237 * @return true if successful, false otherwise. 00238 */ 00239 virtual bool apply(channel& srcdest) const; 00240 00241 /** 00242 * operates on the given parameter (matrix of integers). 00243 * If this method is not implemented an exception of type 00244 * lti::functor::invalidMethodException will be thrown. 00245 * @param srcdest matrix of integers with the source data. The result 00246 * will be left here too. 00247 * @return true if successful, false otherwise. 00248 */ 00249 virtual bool apply(imatrix& srcdest) const; 00250 00251 /** 00252 * operates on the given parameter (channel of unsigned bytes). 00253 * If this method is not implemented an exception of type 00254 * lti::functor::invalidMethodException will be thrown. 00255 * @param srcdest channel8 with the source data. 00256 * The result will be left here too. 00257 * @return true if successful, false otherwise. 00258 */ 00259 virtual bool apply(matrix<channel8::value_type>& srcdest) const; 00260 00261 /** 00262 * operates on the given parameter (channel of unsigned bytes). 00263 * If this method is not implemented an exception of type 00264 * lti::functor::invalidMethodException will be thrown. 00265 * @param srcdest channel8 with the source data. 00266 * The result will be left here too. 00267 * @return true if successful, false otherwise. 00268 */ 00269 virtual bool apply(channel8& srcdest) const; 00270 00271 /** 00272 * operates on the given image 00273 * The image will be splitted in its RGB components, which will be 00274 * operated with the fastest method, and the results will be merged again. 00275 * @param srcdest lti::image with the source data. The result will be left 00276 * here. 00277 * @return true if successful, false otherwise. 00278 */ 00279 virtual bool apply(image& srcdest) const; 00280 00281 /** 00282 * operates on a copy of the given parameters (vector of floats) 00283 * @param src vector of floats with the source data. 00284 * @param dest vector of floats, where the result will be left. 00285 * @return true if successful, false otherwise. 00286 */ 00287 virtual bool apply(const fvector& src,fvector& dest) const; 00288 00289 /** 00290 * operates on a copy of the given parameters (vector of integers) 00291 * @param src vector of integers with the source data. 00292 * @param dest vector of integers, where the result will be left. 00293 * @return true if successful, false otherwise. 00294 */ 00295 virtual bool apply(const ivector& src,ivector& dest) const; 00296 00297 /** 00298 * operates on a copy of the given parameters (vector of unsigned bytes) 00299 * @param src vector of unsigned bytes with the source data. 00300 * @param dest vector of unsigned bytes, where the result will be left. 00301 * @return true if successful, false otherwise. 00302 */ 00303 virtual bool apply(const vector<ubyte>& src, 00304 vector<ubyte>& dest) const; 00305 00306 /** 00307 * operates on a copy of the given parameters (channel) 00308 * @param src lti::channel with the source data. 00309 * @param dest channel, where the result will be left. 00310 * @return true if successful, false otherwise. 00311 */ 00312 virtual bool apply(const matrix<channel::value_type>& src, 00313 matrix<channel::value_type>& dest) const; 00314 00315 /** 00316 * operates on a copy of the given parameters (channel) 00317 * @param src lti::channel with the source data. 00318 * @param dest channel, where the result will be left. 00319 * @return true if successful, false otherwise. 00320 */ 00321 virtual bool apply(const channel& src,channel& dest) const; 00322 00323 /** 00324 * operates on a copy of the given parameters (matrix of integers) 00325 * @param src matrix of integers with the source data. 00326 * @param dest matrix of integers, where the result will be left. 00327 * @return true if successful, false otherwise. 00328 */ 00329 virtual bool apply(const imatrix& src,imatrix& dest) const; 00330 00331 /** 00332 * operates on a copy of the given parameters (channel of unsigned bytes) 00333 * @param src lti::channel8 with the source data. 00334 * @param dest lti::channel8, where the result will be left. 00335 * @return true if successful, false otherwise. 00336 */ 00337 virtual bool apply(const matrix<channel8::value_type>& src, 00338 matrix<channel8::value_type>& dest) const; 00339 00340 /** 00341 * operates on a copy of the given parameters (channel of unsigned bytes) 00342 * @param src lti::channel8 with the source data. 00343 * @param dest lti::channel8, where the result will be left. 00344 * @return true if successful, false otherwise. 00345 */ 00346 virtual bool apply(const channel8& src,channel8& dest) const; 00347 00348 00349 /** 00350 * operates on a copy of the given parameters (image) 00351 * The image will be splitted in its RGB components, which will be 00352 * operated with the fastest method, and the results will be merged. 00353 * @param src lti::image with the source data. 00354 * @param dest image, where the result will be left. 00355 * @return true if successful, false otherwise. 00356 */ 00357 virtual bool apply(const image& src,image& dest) const; 00358 00359 /** 00360 * returns the name of this type 00361 */ 00362 virtual const char* getTypeName() const; 00363 00364 protected: 00365 /** 00366 * non const getParameters() 00367 */ 00368 parameters& getParameters(); 00369 }; 00370 } 00371 00372 #endif