latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiFourierDescriptor.h 00027 * authors ....: Norman Pfeil 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 26.4.2001 00030 * revisions ..: $Id: ltiFourierDescriptor.h,v 1.9 2006/02/08 11:08:56 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_FOURIER_DESCRIPTOR_H_ 00034 #define _LTI_FOURIER_DESCRIPTOR_H_ 00035 00036 00037 #include "ltiTransform.h" 00038 #include "ltiRealFFT.h" 00039 #include "ltiRealInvFFT.h" 00040 #include "ltiContour.h" 00041 #include "ltiVector.h" 00042 #include "ltiObjectsFromMask.h" 00043 #include "ltiDraw.h" 00044 #include "ltiMath.h" 00045 00046 namespace lti { 00047 /** 00048 * This class generates fourier descriptors. The input is a list of border points. 00049 * The output are four vectors of fourier descriptors: 00050 * x value (Real,Imaginary) and y value (Real,Imaginary) 00051 * 00052 * The algorithm: http://iul.cs.byu.edu/morse/550-F95/node29.html 00053 * A demo: http://www.stud.ee.ethz.ch/~buc/brechbuehler/fourdem.html 00054 */ 00055 00056 class fourierDescriptor : public transform { 00057 public: 00058 /** 00059 * the parameters for the class fourierDescriptor 00060 */ 00061 class parameters : public transform::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 * write the parameters in 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 * origin is an arbitrary two-dimensional point, default is (0,0). 00148 * It indicates the reference point for calculating the fourier descriptors. 00149 * E.g. the centre of gravity of an object creates translation invariant descriptors. 00150 */ 00151 lti::tpoint<float> origin; 00152 00153 }; 00154 00155 /** 00156 * default constructor 00157 */ 00158 fourierDescriptor(); 00159 00160 /** 00161 * copy constructor 00162 * @param other the object to be copied 00163 */ 00164 fourierDescriptor(const fourierDescriptor& other); 00165 00166 /** 00167 * destructor 00168 */ 00169 virtual ~fourierDescriptor(); 00170 00171 /** 00172 * returns the name of this type ("fourierDescriptor") 00173 */ 00174 virtual const char* getTypeName() const; 00175 00176 /** 00177 * With the given borderpoints and the parameter "origin" (default: 0,0) the apply method calculates the 00178 * fourier descriptors (abscissa real and imaginary value + ordinate real and imaginary value). 00179 * @param input borderPoints with the input data. 00180 * @param xRealOutput vector<float> where the fourier descriptor of the abscissa will be left (real value). 00181 * @param xImagOutput vector<float> where the fourier descriptor of the abscissa will be left (imaginary value). 00182 * @param yRealOutput vector<float> where the fourier descriptor of the ordinate will be left (real value). 00183 * @param yImagOutput vector<float> where the fourier descriptor of the ordinate will be left (imaginary value). 00184 */ 00185 bool apply( const borderPoints& input, 00186 vector<float>& xRealOutput, 00187 vector<float>& xImagOutput, 00188 vector<float>& yRealOutput, 00189 vector<float>& yImagOutput) const; 00190 00191 /** 00192 * Reconstructs borderpoints with given Input and the specified parameter "origin". 00193 * @param xRealInput vector<float> real abscissa value of fourier descriptor. 00194 * @param xImagInput vector<float> imaginary abscissa value of fourier descriptor. 00195 * @param yRealInput vector<float> real ordinate value of fourier descriptor. 00196 * @param yImagInput vector<float> imaginary ordinate value of fourier descriptor. 00197 * @param output borderPoints with the output data. 00198 */ 00199 bool apply( const vector<float>& xRealInput, 00200 const vector<float>& xImagInput, 00201 const vector<float>& yRealInput, 00202 const vector<float>& yImagInput, 00203 borderPoints& output) const; 00204 00205 /** 00206 * copy data of "other" functor. 00207 * @param other the functor to be copied 00208 * @return a reference to this functor object 00209 */ 00210 fourierDescriptor& copy(const fourierDescriptor& other); 00211 00212 /** 00213 * returns a pointer to a clone of this functor. 00214 */ 00215 virtual functor* clone() const; 00216 00217 /** 00218 * returns used parameters 00219 */ 00220 const parameters& getParameters() const; 00221 }; 00222 } 00223 00224 00225 #endif