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 .......: ltiFilledUpsampling.h 00027 * authors ....: Pablo Alvarado, Jochen Wickel 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 12.5.2000 00030 * revisions ..: $Id: ltiFilledUpsampling.h,v 1.9 2006/02/07 18:54:58 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_FILLEDUPSAMPLING_H_ 00034 #define _LTI_FILLEDUPSAMPLING_H_ 00035 00036 #include "ltiObject.h" 00037 #include "ltiFilter.h" 00038 00039 namespace lti { 00040 /** 00041 * Filled Upsampling. 00042 * 00043 * filledUpsampling takes some image or channel and transforms each 00044 * pixel to a filled square. This could also be obtained with 00045 * the upsampling functor and an appropriate kernel, but this one 00046 * is much faster, since it omits all that convolution stuff by default. 00047 * However, convolution can still be performed by supplying an 00048 * external kernel (by calling setKernel). 00049 * 00050 * @see lti::scaling, lti::filledUpsampling, lti::decimation, 00051 * lti::downsampling 00052 * 00053 */ 00054 class filledUpsampling : public filter { 00055 public: 00056 /// the parameters for the class upsampling 00057 class parameters : public filter::parameters { 00058 public: 00059 /// default constructor 00060 parameters(); 00061 00062 /** copy constructor 00063 @param other the parameters object to be copied 00064 */ 00065 parameters(const parameters& other); 00066 00067 /// destructor 00068 ~parameters(); 00069 00070 /// returns name of this type 00071 const char* getTypeName() const; 00072 00073 /** copy the contents of a parameters object 00074 @param other the parameters object to be copied 00075 @return a reference to this parameters object 00076 */ 00077 parameters& copy(const parameters& other); 00078 00079 /// returns a pointer to a clone of the parameters 00080 virtual functor::parameters* clone() const; 00081 00082 /** returns the kernel in use. If it is not set yet, a dummy kernel 00083 will be returned 00084 @return a const reference to the filter kernel. 00085 */ 00086 const mathObject& getKernel() const; 00087 00088 /** 00089 * sets the filter kernel to be used. 00090 * A copy of the given parameter will be made! 00091 * This parameter is optional. If not given the "normal" filled 00092 * upsampling will be done. If given, after the filled-upsampling 00093 * the resulting image will be convolved with the kernel. 00094 * @param aKernel the filter kernel to be used 00095 */ 00096 void setKernel(const mathObject& aKernel); 00097 00098 /** 00099 * write the parameters in the given ioHandler 00100 * @param handler the ioHandler to be used 00101 * @param complete if true (the default) the enclosing begin/end will 00102 * be also written, otherwise only the data block will be written. 00103 * @return true if write was successful 00104 */ 00105 virtual bool write(ioHandler& handler,const bool complete=true) const; 00106 00107 /** 00108 * write the parameters in the given ioHandler 00109 * @param handler the ioHandler to be used 00110 * @param complete if true (the default) the enclosing begin/end will 00111 * be also written, otherwise only the data block will be written. 00112 * @return true if write was successful 00113 */ 00114 virtual bool read(ioHandler& handler,const bool complete=true); 00115 00116 # ifdef _LTI_MSC_6 00117 /** 00118 * this function is required by MSVC only, as a workaround for a 00119 * very awful bug, which exists since MSVC V.4.0, and still by 00120 * V.6.0 with all bugfixes (so called "service packs") remains 00121 * there... This method is public due to another bug, so please 00122 * NEVER EVER call this method directly: use read() instead! 00123 */ 00124 bool readMS(ioHandler& handler,const bool complete=true); 00125 00126 /** 00127 * this function is required by MSVC only, as a workaround for a 00128 * very awful bug, which exists since MSVC V.4.0, and still by 00129 * V.6.0 with all bugfixes (so called "service packs") remains 00130 * there... This method is public due to another bug, so please 00131 * NEVER EVER call this method directly: use write() instead! 00132 */ 00133 bool writeMS(ioHandler& handler,const bool complete=true) const; 00134 # endif 00135 00136 /// interpolation filter 00137 mathObject* kernel; 00138 00139 /// upsampling factor 00140 point factor; 00141 }; 00142 00143 /** 00144 * default constructor 00145 */ 00146 filledUpsampling(); 00147 00148 /** 00149 * constructor to give directly the scaling factor 00150 */ 00151 filledUpsampling(const point& factor); 00152 00153 /** 00154 * constructor to give directly the scaling factor 00155 */ 00156 filledUpsampling(const int& factor); 00157 00158 /** 00159 * copy constructor 00160 * @param other the object to be copied 00161 */ 00162 filledUpsampling(const filledUpsampling& other); 00163 00164 /// destructor 00165 virtual ~filledUpsampling(); 00166 00167 /// returns the name of this type ("filledUpsampling") 00168 virtual const char* getTypeName() const; 00169 00170 /** operates on the given parameter. 00171 @param srcdest channel8 with the source data. The result 00172 will be left here too. 00173 @return true if successful, false otherwise. 00174 */ 00175 bool apply(channel8& srcdest) const; 00176 00177 /** operates on the given parameter. 00178 @param srcdest channel with the source data. The result 00179 will be left here too. 00180 @return true if successful, false otherwise. 00181 */ 00182 bool apply(channel& srcdest) const; 00183 00184 /** 00185 * operates on the given parameter. 00186 * @param srcdest image with the source data. The result 00187 * will be left here too. 00188 * @return true if successful, false otherwise. 00189 */ 00190 bool apply(image& srcdest) const; 00191 00192 /** 00193 * operates on the given parameter. 00194 * @param srcdest dmatrix with the source data. The result 00195 * will be left here too. 00196 * @return true if successful, false otherwise. 00197 */ 00198 bool apply(dmatrix& srcdest) const; 00199 00200 /** 00201 * operates on the given parameter. 00202 * @param srcdest image with the source data. The result 00203 * will be left here too. 00204 * @return true if successful, false otherwise. 00205 */ 00206 bool apply(imatrix& srcdest) const; 00207 00208 /** operates on the given parameter. 00209 @param srcdest vector<channel8::value_type> with the source data. 00210 The result will be left here too. 00211 @return true if successful, false otherwise. 00212 */ 00213 bool apply(vector<channel8::value_type>& srcdest) const; 00214 00215 /** operates on the given parameter. 00216 @param srcdest vector<channel::value_type> with the source data. 00217 The result will be left here too. 00218 @return true if successful, false otherwise. 00219 */ 00220 bool apply(vector<channel::value_type>& srcdest) const; 00221 00222 /** operates on a copy of the given parameters. 00223 @param src channel8 with the source data. 00224 @param dest channel8 where the result will be left. 00225 @return true if successful, false otherwise. 00226 */ 00227 bool apply(const channel8& src,channel8& dest) const; 00228 00229 /** operates on a copy of the given parameters. 00230 @param src channel with the source data. 00231 @param dest channel where the result will be left. 00232 @return true if successful, false otherwise. 00233 */ 00234 bool apply(const channel& src,channel& dest) const; 00235 00236 /** 00237 * operates on a copy of the given parameters. 00238 * @param src channel with the source data. 00239 * @param dest channel where the result will be left. 00240 * @return true if successful, false otherwise. 00241 */ 00242 bool apply(const image& src,image& dest) const; 00243 00244 /** 00245 * operates on a copy of the given parameters. 00246 * @param src dmatrix with the source data. 00247 * @param dest dmatrix where the result will be left. 00248 * @return true if successful, false otherwise. 00249 */ 00250 bool apply(const dmatrix& src,dmatrix& dest) const; 00251 00252 /** 00253 * operates on a copy of the given parameters. 00254 * @param src channel with the source data. 00255 * @param dest channel where the result will be left. 00256 * @return true if successful, false otherwise. 00257 */ 00258 bool apply(const imatrix& src,imatrix& dest) const; 00259 00260 /** operates on a copy of the given parameters. 00261 @param src vector<channel8::value_type> with the source data. 00262 @param dest vector<channel8::value_type> where the result will be left. 00263 @return true if successful, false otherwise. 00264 */ 00265 bool apply(const vector<channel8::value_type>& src, 00266 vector<channel8::value_type>& dest) const; 00267 00268 /** operates on a copy of the given parameters. 00269 @param src vector<channel::value_type> with the source data. 00270 @param dest vector<channel::value_type> where the result will be left. 00271 @return true if successful, false otherwise. 00272 */ 00273 bool apply(const vector<channel::value_type>& src, 00274 vector<channel::value_type>& dest) const; 00275 00276 /** 00277 * copy data of "other" functor. 00278 * @param other the functor to be copied 00279 * @return a reference to this functor object 00280 */ 00281 filledUpsampling& copy(const filledUpsampling& other); 00282 00283 /** 00284 * returns a pointer to a clone of this functor. 00285 */ 00286 virtual functor* clone() const; 00287 00288 /** 00289 * returns used parameters 00290 */ 00291 const parameters& getParameters() const; 00292 00293 /** 00294 * shortcut to set the filter kernel in the functor parameters. 00295 * The other parameters remain unchanged. 00296 */ 00297 void setKernel(const mathObject& aKernel); 00298 00299 private: 00300 /** 00301 * this template class does the real upsampling job 00302 */ 00303 template <class T> 00304 class genericUpsampler { 00305 public: 00306 /** 00307 * upsampling of a vector 00308 */ 00309 bool apply(const int& factor, 00310 const vector<T>& src, 00311 vector<T>& dest); 00312 00313 /** 00314 * upsampling of a matrix 00315 */ 00316 bool apply(const point& factor, 00317 const matrix<T>& src, 00318 matrix<T>& dest); 00319 00320 }; 00321 }; 00322 } 00323 00324 #endif