latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiCartesianToPolar.h 00027 * authors ....: Bernd Mussmann 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 18.8.2000 00030 * revisions ..: $Id: ltiCartesianToPolar.h,v 1.9 2006/02/07 18:34:51 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_CARTESIAN_TO_POLAR_H_ 00034 #define _LTI_CARTESIAN_TO_POLAR_H_ 00035 00036 //include files which are needed 00037 00038 #include "ltiMatrix.h" 00039 #include "ltiVector.h" 00040 #include "ltiPointList.h" 00041 #include "ltiArctanLUT.h" 00042 // include parent class: 00043 #include "ltiTransform.h" 00044 00045 namespace lti { 00046 /** 00047 * Computes the elements of the polar coordinate system 00048 * (value,phase) based on the parameters of the cartesian 00049 * coordinate system (x,y). 00050 */ 00051 template<class T> 00052 class cartesianToPolar : public transform { 00053 public: 00054 /** 00055 * value type of the used matrices 00056 */ 00057 typedef T value_type; 00058 00059 /** 00060 * the parameters for the class cartesianToPolar 00061 */ 00062 class parameters : public transform::parameters { 00063 public: 00064 /** 00065 * default constructor 00066 */ 00067 parameters(): transform::parameters() { 00068 // Initialize default parameter values 00069 useLUT = false; 00070 }; 00071 00072 /** 00073 * copy constructor 00074 * @param other the parameters object to be copied 00075 */ 00076 parameters(const parameters& other) 00077 : transform::parameters() { 00078 copy(other); 00079 }; 00080 00081 /** 00082 * destructor 00083 */ 00084 ~parameters() {}; 00085 00086 /** 00087 * returns name of this type 00088 */ 00089 const char* getTypeName() const { 00090 return "cartesianToPolar::parameters"; 00091 }; 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& copy(const parameters& other) { 00099 # ifndef _LTI_MSC_6 00100 // MS Visual C++ 6 is not able to compile this... 00101 transform::parameters::copy(other); 00102 # else 00103 // ...so we have to use this workaround. 00104 // Conditional on that, copy may not be virtual. 00105 transform::parameters& (transform::parameters::* p_copy) 00106 (const transform::parameters&) = 00107 transform::parameters::copy; 00108 (this->*p_copy)(other); 00109 # endif 00110 00111 useLUT = other.useLUT; 00112 00113 return *this; 00114 }; 00115 00116 /** 00117 * returns a pointer to a clone of the parameters 00118 */ 00119 virtual functor::parameters* clone() const { 00120 return new parameters(*this); 00121 }; 00122 00123 // ------------------------------------------------ 00124 // the parameters 00125 // ------------------------------------------------ 00126 00127 /** 00128 * useLUT specifies if arctanLUT is used to calculate atan values 00129 * 00130 * Default Value: false; 00131 */ 00132 bool useLUT; 00133 00134 }; 00135 00136 /** 00137 * default constructor 00138 */ 00139 cartesianToPolar(); 00140 00141 /** 00142 * constructor with parameters 00143 */ 00144 cartesianToPolar(const parameters& thePars); 00145 00146 /** 00147 * constructor which uses the arctan lookup table if its argument is true 00148 */ 00149 cartesianToPolar(bool useLUT); 00150 00151 /** 00152 * copy constructor 00153 * @param other the object to be copied 00154 */ 00155 cartesianToPolar(const cartesianToPolar& other); 00156 00157 /** 00158 * destructor 00159 */ 00160 virtual ~cartesianToPolar(); 00161 00162 /** 00163 * returns the name of this type ("cartesianToPolar") 00164 */ 00165 virtual const char* getTypeName() const; 00166 00167 /** 00168 * operates on the given parameter. 00169 * @param r_abs the real part of the source data 00170 * (magnitude will be left here). 00171 * @param i_ph the imaginary part of the source data 00172 * (phase will be left here). 00173 */ 00174 bool apply(matrix<T>& r_abs ,matrix<T>& i_ph); 00175 00176 /** 00177 * operates on the given parameter. 00178 * @param r_abs the real part of the source data 00179 * (magnitude will be left here). 00180 * @param i_ph the imaginary part of the source data 00181 * (phase will be left here). 00182 */ 00183 bool apply(vector<T>& r_abs ,vector<T>& i_ph); 00184 00185 /** 00186 * operates on a copy of the given parameters. 00187 * If the source matrices have different sizes, the returned data 00188 * will be empty. 00189 * @param real matrix<T> with the real source data. 00190 * @param imaginary matrix<T> the imaginary source data. 00191 * @param absvalue absolute value of the input data. 00192 * @param phase phase of the input data. 00193 */ 00194 bool apply(const matrix<T>& real, 00195 const matrix<T>& imaginary, 00196 matrix<T>& absvalue, 00197 matrix<T>& phase); 00198 00199 /** 00200 * operates on a copy of the given parameters. 00201 * If the source matrices have different sizes, the returned data 00202 * will be empty. 00203 * @param real vector with the real part of the source data. 00204 * @param imaginary vector the imaginary part of the source data. 00205 * @param absvalue absolute value of the input data. 00206 * @param phase phase of the input data. 00207 */ 00208 bool apply(const vector<T>& real, 00209 const vector<T>& imaginary, 00210 vector<T>& absvalue, 00211 vector<T>& phase); 00212 00213 /** 00214 * operates on a copy of the given parameters. 00215 * When this apply is invoked the Arctan Lookup Table is not used 00216 * regardless of the useLUT parameter. 00217 * @param src list of points with the cartesian data. 00218 * @param dest resulting list, in which the points contains in their 00219 * member x the magnitude (or radius) and the angle in the y. 00220 * @param origin optional parameter which gives the position considered 00221 * as origin for the cartesic-polar conversion 00222 */ 00223 bool apply(const tpointList<T>& src, 00224 tpointList<double> &dest, 00225 const tpoint<double> origin=tpoint<double>(0.0,0.0) ) const; 00226 00227 00228 /** 00229 * copy data of "other" functor. 00230 * @param other the functor to be copied 00231 * @return a reference to this functor object 00232 */ 00233 cartesianToPolar& copy(const cartesianToPolar& other); 00234 00235 /** 00236 * returns a pointer to a clone of this functor. 00237 */ 00238 virtual functor* clone() const; 00239 00240 /** 00241 * returns used parameters 00242 */ 00243 const parameters& getParameters() const; 00244 00245 }; 00246 00247 } 00248 00249 #endif