last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 1998 - 2005 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * 00006 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00007 * 00008 * The CVR-Lib is free software; you can redistribute it and/or 00009 * modify it under the terms of the BSD License. 00010 * 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. Neither the name of the authors nor the names of its contributors may be 00024 * used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 */ 00039 00040 00041 /** 00042 * \file cvrFilledUpsampling.h 00043 * \author Pablo Alvarado 00044 * \author Jochen Wickel 00045 * \date 12.5.2000 00046 * 00047 * $Id: cvrFilledUpsampling.h,v 1.4 2005/05/08 18:29:47 arndh Exp $ 00048 */ 00049 00050 #ifndef _CVR_FILLEDUPSAMPLING_H_ 00051 #define _CVR_FILLEDUPSAMPLING_H_ 00052 00053 #include "cvrFunctor.h" 00054 #include "cvrVector.h" 00055 #include "cvrMatrix.h" 00056 00057 namespace cvr { 00058 /** 00059 * Filled upsampling (or upsampling with zero-order interpolation) 00060 * 00061 * The class cvr::filledUpsampling takes some image or channel and transforms 00062 * each pixel to a filled square. This could also be obtained with the 00063 * upsampling functor and an appropriate kernel, but this one is much faster, 00064 * since it omits all convolution overhead. 00065 * 00066 * @ingroup gLinearFilters 00067 */ 00068 class filledUpsampling : public functor { 00069 public: 00070 /** 00071 * The parameters for the class cvr::filledUpsampling 00072 */ 00073 class parameters : public functor::parameters { 00074 public: 00075 /** 00076 * Default constructor 00077 */ 00078 parameters(); 00079 00080 /** 00081 * Copy constructor 00082 * @param other the parameters object to be copied 00083 */ 00084 parameters(const parameters& other); 00085 00086 /** 00087 * Destructor 00088 */ 00089 ~parameters(); 00090 00091 /** 00092 * Returns name of this type 00093 */ 00094 const std::string& name() const; 00095 00096 /** 00097 * Copy the contents of a parameters object 00098 * 00099 * @param other the parameters object to be copied 00100 * @return a reference to this parameters object 00101 */ 00102 parameters& copy(const parameters& other); 00103 00104 /** 00105 * Returns a pointer to a clone of the parameters 00106 */ 00107 virtual filledUpsampling::parameters* clone() const; 00108 00109 /** 00110 * Returns a pointer to a new instance of the parameters 00111 */ 00112 virtual filledUpsampling::parameters* newInstance() const; 00113 00114 /** 00115 * write the parameters in the given ioHandler 00116 * @param handler the ioHandler to be used 00117 * @param complete if true (the default) the enclosing begin/end will 00118 * be also written, otherwise only the data block will be written. 00119 * @return true if write was successful 00120 */ 00121 virtual bool write(ioHandler& handler,const bool complete=true) const; 00122 00123 /** 00124 * write the parameters in the given ioHandler 00125 * @param handler the ioHandler to be used 00126 * @param complete if true (the default) the enclosing begin/end will 00127 * be also written, otherwise only the data block will be written. 00128 * @return true if write was successful 00129 */ 00130 virtual bool read(ioHandler& handler,const bool complete=true); 00131 00132 /** 00133 * Upsampling factor. 00134 * 00135 * The x component is meant for the horizontal upsampling and the y 00136 * component for the vertical upsampling. 00137 * 00138 * If you are filtering vectors, only the x component will be used. 00139 * 00140 * Default value: (2,2) 00141 */ 00142 ipoint factor; 00143 }; 00144 00145 /** 00146 * Default constructor 00147 */ 00148 filledUpsampling(); 00149 00150 /** 00151 * Constructor to give directly the scaling factor 00152 */ 00153 filledUpsampling(const ipoint& factor); 00154 00155 /** 00156 * Constructor to give directly the scaling factor 00157 */ 00158 filledUpsampling(const int factor); 00159 00160 /** 00161 * Copy constructor 00162 * @param other the object to be copied 00163 */ 00164 filledUpsampling(const filledUpsampling& other); 00165 00166 /** 00167 * Destructor 00168 */ 00169 virtual ~filledUpsampling(); 00170 00171 /** 00172 * Returns the name of this type 00173 */ 00174 virtual const std::string& name() const; 00175 00176 /** 00177 * Operates on the given parameter. 00178 * 00179 * @param srcdest channel or matrix with the source data. The result 00180 * will be left here too. 00181 * @return true if successful, false otherwise. 00182 */ 00183 template<typename T> 00184 bool apply(matrix<T>& srcdest) const; 00185 00186 /** 00187 * Operates on the given parameter. 00188 * @param srcdest vector with the source data. 00189 * The result will be left here too. 00190 * @return true if successful, false otherwise. 00191 */ 00192 template<typename T> 00193 bool apply(vector<T>& srcdest) const; 00194 00195 /** 00196 * Operates on a copy of the given parameters. 00197 * @param src channel or matrix with the source data. 00198 * @param dest channel or matrix where the result will be left. 00199 * @return true if successful, false otherwise. 00200 */ 00201 template<typename T> 00202 bool apply(const matrix<T>& src,matrix<T>& dest) const; 00203 00204 /** 00205 * Operates on a copy of the given parameters. 00206 * 00207 * @param src vector with the source data. 00208 * @param dest vector where the result will be left. 00209 * @return true if successful, false otherwise. 00210 */ 00211 template<typename T> 00212 bool apply(const vector<T>& src, 00213 vector<T>& dest) const; 00214 00215 /** 00216 * Operates on the given parameter. 00217 * @param factor upsampling factor (this method ignores the value in 00218 * the parameters). 00219 * @param srcdest channel or matrix with the source data. The result 00220 * will be left here too. 00221 * @return true if successful, false otherwise. 00222 */ 00223 template<typename T> 00224 bool apply(const ipoint& factor, 00225 matrix<T>& srcdest) const; 00226 00227 /** 00228 * Operates on the given parameter. 00229 * @param factor upsampling factor (this method ignores the value in 00230 * the parameters). 00231 * @param srcdest vector with the source data. 00232 * The result will be left here too. 00233 * @return true if successful, false otherwise. 00234 */ 00235 template<typename T> 00236 bool apply(const int factor,vector<T>& srcdest) const; 00237 00238 /** 00239 * Operates on a copy of the given parameters. 00240 * @param factor upsampling factor (this method ignores the value in 00241 * the parameters). 00242 * @param src channel or matrix with the source data. 00243 * @param dest channel or matrix where the result will be left. 00244 * @return true if successful, false otherwise. 00245 */ 00246 template<typename T> 00247 bool apply(const ipoint& factor, 00248 const matrix<T>& src, 00249 matrix<T>& dest) const; 00250 00251 /** 00252 * Operates on a copy of the given parameters. 00253 * 00254 * @param factor upsampling factor (this method ignores the value in 00255 * the parameters). 00256 * @param src vector with the source data. 00257 * @param dest vector where the result will be left. 00258 * @return true if successful, false otherwise. 00259 */ 00260 template<typename T> 00261 bool apply(const int factor, 00262 const vector<T>& src, 00263 vector<T>& dest) const; 00264 00265 00266 /** 00267 * Copy data of "other" functor. 00268 * @param other the functor to be copied 00269 * @return a reference to this functor object 00270 */ 00271 filledUpsampling& copy(const filledUpsampling& other); 00272 00273 /** 00274 * Returns a pointer to a clone of this functor. 00275 */ 00276 virtual functor* clone() const; 00277 00278 /** 00279 * Returns a pointer to a new instance of this functor. 00280 */ 00281 virtual functor* newInstance() const; 00282 00283 /** 00284 * Returns used parameters 00285 */ 00286 const parameters& getParameters() const; 00287 }; 00288 } 00289 00290 #include "cvrFilledUpsampling_template.h" 00291 00292 #endif 00293