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 .......: ltiUpsampling.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 12.5.2000 00030 * revisions ..: $Id: ltiUpsampling.h,v 1.10 2006/02/07 19:49:49 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_UPSAMPLING_H_ 00034 #define _LTI_UPSAMPLING_H_ 00035 00036 #include "ltiObject.h" 00037 #include "ltiFilter.h" 00038 00039 namespace lti { 00040 /** 00041 * Upsampling is the complementary functor to lti::downsampling 00042 * 00043 * This %functor scales up the given data with an integer factor. 00044 * 00045 * It will use the interpolation filter and upsampling factors given by 00046 * upsampling::parameters. 00047 * 00048 * If you need interpolation among the samples you should consider 00049 * lti::scaling. 00050 * 00051 * @see lti::scaling, lti::filledUpsampling, lti::decimation, 00052 * lti::downsampling 00053 * 00054 * @ingroup gLinearFilters 00055 */ 00056 class upsampling : public filter { 00057 public: 00058 /** 00059 * the parameters for the class upsampling 00060 */ 00061 class parameters : public filter::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 * returns a pointer to a clone of the parameters 00093 */ 00094 virtual functor::parameters* clone() const; 00095 00096 /** 00097 * Return a const reference to the kernel in use. 00098 * 00099 * If it is not set yet, an lti::invalidParameters exception 00100 * will be thrown. 00101 * 00102 * The default value for this kernel is a 3x3 mask, generated as 00103 * the outer product of (0.5,1,0.5) with itself. (It is 00104 * implemented as a separable kernel, of course!) 00105 * 00106 * @return a const reference to the filter kernel. 00107 */ 00108 const mathObject& getKernel() const; 00109 00110 /** 00111 * Set the filter kernel to be used. 00112 * 00113 * A copy of the given parameter will be made! 00114 * 00115 * @param aKernel the filter kernel to be used. 00116 * 00117 * If the kernel is not explicitly set, the default value will 00118 * be a 3x3 mask, generated as the outer product of (0.5,1,0.5) 00119 * with itself. (It is implemented as a separable kernel, of 00120 * course!) 00121 */ 00122 void setKernel(const mathObject& aKernel); 00123 00124 /** 00125 * write the parameters in the given ioHandler 00126 * @param handler the ioHandler to be used 00127 * @param complete if true (the default) the enclosing begin/end will 00128 * be also written, otherwise only the data block will be written. 00129 * @return true if write was successful 00130 */ 00131 virtual bool write(ioHandler& handler,const bool complete=true) const; 00132 00133 /** 00134 * write the parameters in the given ioHandler 00135 * @param handler the ioHandler to be used 00136 * @param complete if true (the default) the enclosing begin/end will 00137 * be also written, otherwise only the data block will be written. 00138 * @return true if write was successful 00139 */ 00140 virtual bool read(ioHandler& handler,const bool complete=true); 00141 00142 # ifdef _LTI_MSC_6 00143 /** 00144 * this function is required by MSVC only, as a workaround for a 00145 * very awful bug, which exists since MSVC V.4.0, and still by 00146 * V.6.0 with all bugfixes (so called "service packs") remains 00147 * there... This method is public due to another bug, so please 00148 * NEVER EVER call this method directly: use read() instead! 00149 */ 00150 bool readMS(ioHandler& handler,const bool complete=true); 00151 00152 /** 00153 * this function is required by MSVC only, as a workaround for a 00154 * very awful bug, which exists since MSVC V.4.0, and still by 00155 * V.6.0 with all bugfixes (so called "service packs") remains 00156 * there... This method is public due to another bug, so please 00157 * NEVER EVER call this method directly: use write() instead! 00158 */ 00159 bool writeMS(ioHandler& handler,const bool complete=true) const; 00160 # endif 00161 00162 /** 00163 * Upsampling factor. 00164 * 00165 * Default value: (2,2) 00166 */ 00167 point factor; 00168 00169 protected: 00170 /** 00171 * Interpolation filter 00172 * @see setKernel() 00173 */ 00174 mathObject* kernel; 00175 }; 00176 00177 /** 00178 * Default constructor 00179 */ 00180 upsampling(); 00181 00182 /** 00183 * Constructor with parameters 00184 */ 00185 upsampling(const parameters& par); 00186 00187 /** 00188 * copy constructor 00189 * @param other the object to be copied 00190 */ 00191 upsampling(const upsampling& other); 00192 00193 /** 00194 * destructor 00195 */ 00196 virtual ~upsampling(); 00197 00198 /** 00199 * returns the name of this type ("upsampling") 00200 */ 00201 virtual const char* getTypeName() const; 00202 00203 /** 00204 * operates on the given parameter. 00205 * @param srcdest channel8 with the source data. The result 00206 * will be left here too. 00207 * @result a reference to the <code>srcdest</code>. 00208 */ 00209 bool apply(channel8& srcdest) const; 00210 00211 /** 00212 * operates on the given parameter. 00213 * @param srcdest channel with the source data. The result 00214 * will be left here too. 00215 * @result a reference to the <code>srcdest</code>. 00216 */ 00217 bool apply(channel& srcdest) const; 00218 00219 /** 00220 * operates on the given parameter. 00221 * @param srcdest vector<channel8::value_type> with the source data. 00222 * The result will be left here too. 00223 * @result a reference to the <code>srcdest</code>. 00224 */ 00225 bool apply(vector<channel8::value_type>& srcdest) const; 00226 00227 /** 00228 * operates on the given parameter. 00229 * @param srcdest vector<channel::value_type> with the source data. 00230 * The result will be left here too. 00231 * @result a reference to the <code>srcdest</code>. 00232 */ 00233 bool apply(vector<channel::value_type>& srcdest) const; 00234 00235 /** 00236 * operates on a copy of the given parameters. 00237 * @param src channel8 with the source data. 00238 * @param dest channel8 where the result will be left. 00239 * @result true if ok, false otherwise. 00240 */ 00241 bool apply(const channel8& src,channel8& dest) const; 00242 00243 /** 00244 * operates on a copy of the given parameters. 00245 * @param src channel with the source data. 00246 * @param dest channel where the result will be left. 00247 * @result true if ok, false otherwise. 00248 */ 00249 bool apply(const channel& src,channel& dest) const; 00250 00251 /** 00252 * operates on a copy of the given parameters. 00253 * @param src vector<channel8::value_type> with the source data. 00254 * @param dest vector<channel8::value_type> where the result will be left. 00255 * @result true if ok, false otherwise. 00256 */ 00257 bool apply(const vector<channel8::value_type>& src, 00258 vector<channel8::value_type>& dest) const; 00259 00260 /** 00261 * operates on a copy of the given parameters. 00262 * @param src vector<channel::value_type> with the source data. 00263 * @param dest vector<channel::value_type> where the result will be left. 00264 * @result true if ok, false otherwise. 00265 */ 00266 bool apply(const vector<channel::value_type>& src, 00267 vector<channel::value_type>& dest) const; 00268 00269 /** 00270 * copy data of "other" functor. 00271 * @param other the functor to be copied 00272 * @return a reference to this functor object 00273 */ 00274 upsampling& copy(const upsampling& other); 00275 00276 /** 00277 * returns a pointer to a clone of this functor. 00278 */ 00279 virtual functor* clone() const; 00280 00281 /** 00282 * returns used parameters 00283 */ 00284 const parameters& getParameters() const; 00285 00286 /** 00287 * shortcut to set the filter kernel in the functor parameters. 00288 * The other parameters remain unchanged. 00289 */ 00290 void setKernel(const mathObject& aKernel); 00291 00292 }; 00293 } 00294 00295 #endif