latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiPointSetNormalization.h 00027 * authors ....: Claudia Goenner 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 29.3.2004 00030 * revisions ..: $Id: ltiPointSetNormalization.h,v 1.5 2006/02/08 11:38:20 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_POINT_SET_NORMALIZATION_H_ 00034 #define _LTI_POINT_SET_NORMALIZATION_H_ 00035 00036 #include "ltiFunctor.h" 00037 #include "ltiVector.h" 00038 #include "ltiPoint.h" 00039 00040 namespace lti { 00041 00042 /** 00043 * A parent class for normalizations of point sets. All derived 00044 * normalizations may include translation and scaling and are 00045 * defined by the following formula: 00046 * 00047 * \code 00048 * tpoint<T> normedPt; 00049 * tpoint<T> pt; 00050 * tpoint<T> scale; 00051 * tpoint<T> shift; 00052 * normedPt = scale * pt + shift 00053 * \endcode 00054 * 00055 * If estimating e.g. a transform by least squares it is advised to perform 00056 * such a normalization. A transform between normalized data might not be 00057 * the same as for the original data. Therefore it is important to follow 00058 * the above definition because otherwise the undo-operations implemented 00059 * for e.g. the transformEstimator will not work. 00060 * 00061 * @see isotropicNormalization 00062 */ 00063 class pointSetNormalization : public functor { 00064 public: 00065 /** 00066 * The parameters for the class pointSetNormalization 00067 */ 00068 class parameters : public functor::parameters { 00069 public: 00070 /** 00071 * Default constructor 00072 */ 00073 parameters(); 00074 00075 /** 00076 * Copy constructor 00077 * @param other the parameters object to be copied 00078 */ 00079 parameters(const parameters& other); 00080 00081 /** 00082 * Destructor 00083 */ 00084 ~parameters(); 00085 00086 /** 00087 * Returns name of this type 00088 */ 00089 const char* getTypeName() const; 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& copy(const parameters& other); 00097 00098 /** 00099 * Copy the contents of a parameters object 00100 * @param other the parameters object to be copied 00101 * @return a reference to this parameters object 00102 */ 00103 parameters& operator=(const parameters& other); 00104 00105 00106 /** 00107 * Returns a pointer to a clone of the parameters 00108 */ 00109 virtual functor::parameters* clone() const; 00110 00111 /** 00112 * Write the parameters in the given ioHandler 00113 * @param handler the ioHandler to be used 00114 * @param complete if true (the default) the enclosing begin/end will 00115 * be also written, otherwise only the data block will be written. 00116 * @return true if write was successful 00117 */ 00118 virtual bool write(ioHandler& handler,const bool complete=true) const; 00119 00120 /** 00121 * Read the parameters from the given ioHandler 00122 * @param handler the ioHandler to be used 00123 * @param complete if true (the default) the enclosing begin/end will 00124 * be also written, otherwise only the data block will be written. 00125 * @return true if write was successful 00126 */ 00127 virtual bool read(ioHandler& handler,const bool complete=true); 00128 00129 # ifdef _LTI_MSC_6 00130 /** 00131 * This function is required by MSVC only, as a workaround for a 00132 * very awful bug, which exists since MSVC V.4.0, and still by 00133 * V.6.0 with all bugfixes (so called "service packs") remains 00134 * there... This method is also public due to another bug, so please 00135 * NEVER EVER call this method directly: use read() instead 00136 */ 00137 bool readMS(ioHandler& handler,const bool complete=true); 00138 00139 /** 00140 * This function is required by MSVC only, as a workaround for a 00141 * very awful bug, which exists since MSVC V.4.0, and still by 00142 * V.6.0 with all bugfixes (so called "service packs") remains 00143 * there... This method is also public due to another bug, so please 00144 * NEVER EVER call this method directly: use write() instead 00145 */ 00146 bool writeMS(ioHandler& handler,const bool complete=true) const; 00147 # endif 00148 00149 // ------------------------------------------------ 00150 // the parameters 00151 // ------------------------------------------------ 00152 00153 }; 00154 00155 /** 00156 * Default constructor 00157 */ 00158 pointSetNormalization(); 00159 00160 /** 00161 * Construct a functor using the given parameters 00162 */ 00163 pointSetNormalization(const parameters& par); 00164 00165 /** 00166 * Copy constructor 00167 * @param other the object to be copied 00168 */ 00169 pointSetNormalization(const pointSetNormalization& other); 00170 00171 /** 00172 * Destructor 00173 */ 00174 virtual ~pointSetNormalization(); 00175 00176 /** 00177 * Returns the name of this type ("pointSetNormalization") 00178 */ 00179 virtual const char* getTypeName() const; 00180 00181 /** 00182 * Normalizes the supplied point vector. 00183 * operates on the given %parameter. 00184 * @param srcdest vector<fpoint> with the source data. The result 00185 * will be left here too. 00186 * @return true if apply successful or false otherwise. 00187 */ 00188 virtual bool apply(vector<fpoint>& srcdest) const = 0; 00189 00190 /** 00191 * Normalizes the supplied point vector as defined by 00192 * normedPt = scale * pt + shift. The parameters scale and shift 00193 * are computed automatically. 00194 * operates on the given %parameter. 00195 * @param srcdest vector<fpoint> with the source data. The result 00196 * will be left here too. 00197 * @param scale fpoint where the applied scale will be left 00198 * @param shift fpoint where the applied shift will be left 00199 * @return true if apply successful or false otherwise. 00200 */ 00201 virtual bool apply(vector<fpoint>& srcdest, 00202 fpoint& scale, fpoint& shift) const = 0; 00203 00204 /** 00205 * Normalizes the supplied point vector. 00206 * operates on the given %parameter. 00207 * @param srcdest vector<dpoint> with the source data. The result 00208 * will be left here too. 00209 * @return true if apply successful or false otherwise. 00210 */ 00211 virtual bool apply(vector<dpoint>& srcdest) const = 0; 00212 00213 /** 00214 * Normalizes the supplied point vector as defined by 00215 * normedPt = scale * pt + shift. The parameters scale and shift 00216 * are computed automatically. 00217 * operates on the given %parameter. 00218 * @param srcdest vector<dpoint> with the source data. The result 00219 * will be left here too. 00220 * @param scale dpoint where the applied scale will be left 00221 * @param shift dpoint where the applied shift will be left 00222 * @return true if apply successful or false otherwise. 00223 */ 00224 virtual bool apply(vector<dpoint>& srcdest, 00225 dpoint& scale, dpoint& shift) const = 0; 00226 00227 /** 00228 * Normalizes the supplied point vector. 00229 * operates on a copy of the given %parameters. 00230 * @param src vector<fpoint> with the source data. 00231 * @param dest vector<fpoint> where the result will be left. 00232 * @return true if apply successful or false otherwise. 00233 */ 00234 virtual bool apply(const vector<fpoint>& src,vector<fpoint>& dest) const 00235 = 0; 00236 00237 /** 00238 * Normalizes the supplied point vector as defined by 00239 * normedPt = scale * pt + shift. The parameters scale and shift 00240 * are computed automatically. 00241 * operates on a copy of the given %parameters. 00242 * @param src vector<fpoint> with the source data. 00243 * @param dest vector<fpoint> where the result will be left. 00244 * @param scale fpoint where the applied scale will be left 00245 * @param shift fpoint where the applied shift will be left 00246 * @return true if apply successful or false otherwise. 00247 */ 00248 virtual bool apply(const vector<fpoint>& src,vector<fpoint>& dest, 00249 fpoint& scale, fpoint& shift) const = 0; 00250 00251 /** 00252 * Normalizes the supplied point vector. 00253 * operates on a copy of the given %parameters. 00254 * @param src vector<dpoint> with the source data. 00255 * @param dest vector<dpoint> where the result will be left. 00256 * @return true if apply successful or false otherwise. 00257 */ 00258 virtual bool apply(const vector<dpoint>& src,vector<dpoint>& dest) const 00259 = 0; 00260 00261 /** 00262 * Normalizes the supplied point vector as defined by 00263 * normedPt = scale * pt + shift. The parameters scale and shift 00264 * are computed automatically. 00265 * operates on a copy of the given %parameters. 00266 * @param src vector<dpoint> with the source data. 00267 * @param dest vector<dpoint> where the result will be left. 00268 * @param scale dpoint where the applied scale will be left 00269 * @param shift dpoint where the applied shift will be left 00270 * @return true if apply successful or false otherwise. 00271 */ 00272 virtual bool apply(const vector<dpoint>& src,vector<dpoint>& dest, 00273 dpoint& scale, dpoint& shift) const = 0; 00274 00275 /** 00276 * Copy data of "other" functor. 00277 * @param other the functor to be copied 00278 * @return a reference to this functor object 00279 */ 00280 pointSetNormalization& copy(const pointSetNormalization& other); 00281 00282 /** 00283 * Alias for copy member 00284 * @param other the functor to be copied 00285 * @return a reference to this functor object 00286 */ 00287 pointSetNormalization& operator=(const pointSetNormalization& other); 00288 00289 /** 00290 * Returns a pointer to a clone of this functor. 00291 */ 00292 virtual functor* clone() const = 0; 00293 00294 /** 00295 * Returns used parameters 00296 */ 00297 const parameters& getParameters() const; 00298 00299 }; 00300 } 00301 00302 #endif