![]() |
latest version v1.9 - last update 10 Apr 2010 |
![]() |
00001 /* 00002 * Copyright (C) 2003, 2004, 2005, 2006 00003 * Vlad Popovici, EPFL STI-ITS, Switzerland 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 * file .......: ltiFlipImage.h 00026 * authors ....: Vlad Popovici 00027 * organization: EPFL STI-ITS/LTS1 00028 * creation ...: 20.6.2003 00029 * revisions ..: $Id: ltiFlipImage.h,v 1.9 2006/02/07 18:55:30 ltilib Exp $ 00030 */ 00031 00032 #ifndef _LTI_FLIP_IMAGE_H_ 00033 #define _LTI_FLIP_IMAGE_H_ 00034 00035 #include "ltiModifier.h" 00036 00037 #undef None 00038 00039 namespace lti { 00040 00041 /** 00042 * Flips an image horizontally or vertically. 00043 * 00044 * This is a very simple functor that returns a flipped version 00045 * of the original image. The mirroring can be done along the 00046 * horizontal or vertical axes, or both. 00047 * 00048 * This functor is about 20 times faster in release-mode than using 00049 * the lti::geometricTransform functor. In the debug mode it is 00050 * even 40 times faster! The reason is that the latter functor is 00051 * much more general, and the overhead required for the interpolation and 00052 * rotation (which is zero in this case) is really expensive. 00053 * 00054 * @see lti::geometricTransform, lti::rotation, lti::scaling 00055 * 00056 * @ingroup gGeometry 00057 */ 00058 class flipImage : public modifier { 00059 public: 00060 /** 00061 * the parameters for the class flipImage 00062 */ 00063 class parameters : public modifier::parameters { 00064 public: 00065 /** 00066 * default constructor 00067 */ 00068 parameters(); 00069 00070 /** 00071 * copy constructor 00072 * @param other the parameters object to be copied 00073 */ 00074 parameters(const parameters& other); 00075 00076 /** 00077 * destructor 00078 */ 00079 ~parameters(); 00080 00081 /** 00082 * returns name of this type 00083 */ 00084 const char* getTypeName() const; 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& copy(const parameters& other); 00092 00093 /** 00094 * copy the contents of a parameters object 00095 * @param other the parameters object to be copied 00096 * @return a reference to this parameters object 00097 */ 00098 parameters& operator=(const parameters& other); 00099 00100 00101 /** 00102 * returns a pointer to a clone of the parameters 00103 */ 00104 virtual functor::parameters* clone() const; 00105 00106 /** 00107 * write the parameters in the given ioHandler 00108 * @param handler the ioHandler to be used 00109 * @param complete if true (the default) the enclosing begin/end will 00110 * be also written, otherwise only the data block will be written. 00111 * @return true if write was successful 00112 */ 00113 virtual bool write(ioHandler& handler,const bool complete=true) const; 00114 00115 /** 00116 * read the parameters from the given ioHandler 00117 * @param handler the ioHandler to be used 00118 * @param complete if true (the default) the enclosing begin/end will 00119 * be also written, otherwise only the data block will be written. 00120 * @return true if write was successful 00121 */ 00122 virtual bool read(ioHandler& handler,const bool complete=true); 00123 00124 # ifdef _LTI_MSC_6 00125 /** 00126 * this function is required by MSVC only, as a workaround for a 00127 * very awful bug, which exists since MSVC V.4.0, and still by 00128 * V.6.0 with all bugfixes (so called "service packs") remains 00129 * there... This method is also public due to another bug, so please 00130 * NEVER EVER call this method directly: use read() instead 00131 */ 00132 bool readMS(ioHandler& handler,const bool complete=true); 00133 00134 /** 00135 * this function is required by MSVC only, as a workaround for a 00136 * very awful bug, which exists since MSVC V.4.0, and still by 00137 * V.6.0 with all bugfixes (so called "service packs") remains 00138 * there... This method is also public due to another bug, so please 00139 * NEVER EVER call this method directly: use write() instead 00140 */ 00141 bool writeMS(ioHandler& handler,const bool complete=true) const; 00142 # endif 00143 00144 // ------------------------------------------------ 00145 // the parameters 00146 // ------------------------------------------------ 00147 00148 /** 00149 * Flipping directions. 00150 */ 00151 enum eFlipDirection { 00152 None = 0, /**< Do not flip anything */ 00153 Horizontal, /**< Horizontal flip means to map the top at the 00154 bottom and viceversa */ 00155 Vertical, /**< Vertical flip means to map the right side into 00156 the left and viceversa */ 00157 Both /**< Turns image 180 degrees */ 00158 }; 00159 00160 /** 00161 * Axis along which the image will be flipped. 00162 * 00163 * Default value: Horizontal 00164 */ 00165 eFlipDirection direction; 00166 00167 }; 00168 00169 /** 00170 * default constructor 00171 */ 00172 flipImage(); 00173 00174 /** 00175 * Construct a functor using the given parameters 00176 */ 00177 flipImage(const parameters& par); 00178 00179 /** 00180 * copy constructor 00181 * @param other the object to be copied 00182 */ 00183 flipImage(const flipImage& other); 00184 00185 /** 00186 * destructor 00187 */ 00188 virtual ~flipImage(); 00189 00190 /** 00191 * returns the name of this type ("flipImage") 00192 */ 00193 virtual const char* getTypeName() const; 00194 00195 /** 00196 * operates on the given %parameter. 00197 * @param srcdest image with the source data. The result 00198 * will be left here too. 00199 * @return true if apply successful or false otherwise. 00200 */ 00201 bool apply(matrix<rgbPixel>& srcdest) const; 00202 00203 /** 00204 * operates on a copy of the given %parameters. 00205 * @param src image with the source data. 00206 * @param dest image where the result will be left. 00207 * @return true if apply successful or false otherwise. 00208 */ 00209 bool apply(const matrix<rgbPixel>& src,matrix<rgbPixel>& dest) const; 00210 00211 /** 00212 * operates on the given %parameter. 00213 * @param srcdest image with the source data. The result 00214 * will be left here too. 00215 * @return true if apply successful or false otherwise. 00216 */ 00217 bool apply(matrix<float>& srcdest) const; 00218 00219 /** 00220 * operates on a copy of the given %parameters. 00221 * @param src image with the source data. 00222 * @param dest image where the result will be left. 00223 * @return true if apply successful or false otherwise. 00224 */ 00225 bool apply(const matrix<float>& src,matrix<float>& dest) const; 00226 00227 /** 00228 * operates on the given %parameter. 00229 * @param srcdest image with the source data. The result 00230 * will be left here too. 00231 * @return true if apply successful or false otherwise. 00232 */ 00233 bool apply(matrix<ubyte>& srcdest) const; 00234 00235 /** 00236 * operates on a copy of the given %parameters. 00237 * @param src image with the source data. 00238 * @param dest image where the result will be left. 00239 * @return true if apply successful or false otherwise. 00240 */ 00241 bool apply(const matrix<ubyte>& src,matrix<ubyte>& dest) const; 00242 00243 /** 00244 * copy data of "other" functor. 00245 * @param other the functor to be copied 00246 * @return a reference to this functor object 00247 */ 00248 flipImage& copy(const flipImage& other); 00249 00250 /** 00251 * alias for copy member 00252 * @param other the functor to be copied 00253 * @return a reference to this functor object 00254 */ 00255 flipImage& operator=(const flipImage& other); 00256 00257 /** 00258 * returns a pointer to a clone of this functor. 00259 */ 00260 virtual functor* clone() const; 00261 00262 /** 00263 * returns used parameters 00264 */ 00265 const parameters& getParameters() const; 00266 00267 }; 00268 } 00269 00270 #endif