latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiBlueScreen.h 00027 * authors ....: Marius Wolf 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 9.4.2003 00030 * revisions ..: $Id: ltiBlueScreen.h,v 1.9 2006/02/07 18:31:53 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_BLUE_SCREEN_H_ 00034 #define _LTI_BLUE_SCREEN_H_ 00035 00036 00037 #include "ltiTypes.h" 00038 #include "ltiConvolution.h" 00039 #include <ltiRGBPixel.h> 00040 00041 #include "ltiModifier.h" 00042 00043 namespace lti { 00044 00045 /** 00046 * This functor replaces a specified background color of an image 00047 * with another color or another image ("Bluescreen Technique"). 00048 * 00049 * The background color is indicated through a spherical or cubic window 00050 * in the RGB color space. 00051 */ 00052 class blueScreen : public modifier { 00053 public: 00054 00055 /** 00056 * the parameters for the class blueScreen 00057 */ 00058 class parameters : public modifier::parameters { 00059 public: 00060 /** 00061 * default constructor 00062 */ 00063 parameters(); 00064 00065 /** 00066 * copy constructor 00067 * @param other the parameters object to be copied 00068 */ 00069 parameters(const parameters& other); 00070 00071 /** 00072 * destructor 00073 */ 00074 ~parameters(); 00075 00076 /** 00077 * returns name of this type 00078 */ 00079 const char* getTypeName() const; 00080 00081 /** 00082 * copy the contents of a parameters object 00083 * @param other the parameters object to be copied 00084 * @return a reference to this parameters object 00085 */ 00086 parameters& copy(const parameters& other); 00087 00088 /** 00089 * copy the contents of a parameters object 00090 * @param other the parameters object to be copied 00091 * @return a reference to this parameters object 00092 */ 00093 parameters& operator=(const parameters& other); 00094 00095 00096 /** 00097 * returns a pointer to a clone of the parameters 00098 */ 00099 virtual functor::parameters* clone() const; 00100 00101 /** 00102 * write the parameters in the given ioHandler 00103 * @param handler the ioHandler to be used 00104 * @param complete if true (the default) the enclosing begin/end will 00105 * be also written, otherwise only the data block will be written. 00106 * @return true if write was successful 00107 */ 00108 virtual bool write(ioHandler& handler,const bool complete=true) const; 00109 00110 /** 00111 * read the parameters from the given ioHandler 00112 * @param handler the ioHandler to be used 00113 * @param complete if true (the default) the enclosing begin/end will 00114 * be also written, otherwise only the data block will be written. 00115 * @return true if write was successful 00116 */ 00117 virtual bool read(ioHandler& handler,const bool complete=true); 00118 00119 # ifdef _LTI_MSC_6 00120 /** 00121 * this function is required by MSVC only, as a workaround for a 00122 * very awful bug, which exists since MSVC V.4.0, and still by 00123 * V.6.0 with all bugfixes (so called "service packs") remains 00124 * there... This method is also public due to another bug, so please 00125 * NEVER EVER call this method directly: use read() instead 00126 */ 00127 bool readMS(ioHandler& handler,const bool complete=true); 00128 00129 /** 00130 * this function is required by MSVC only, as a workaround for a 00131 * very awful bug, which exists since MSVC V.4.0, and still by 00132 * V.6.0 with all bugfixes (so called "service packs") remains 00133 * there... This method is also public due to another bug, so please 00134 * NEVER EVER call this method directly: use write() instead 00135 */ 00136 bool writeMS(ioHandler& handler,const bool complete=true) const; 00137 # endif 00138 00139 // ------------------------------------------------ 00140 // the parameters 00141 // ------------------------------------------------ 00142 00143 /** 00144 * Type to define the color space window used to define 00145 * the homogeneous background color that must be replaced by 00146 * another one. 00147 */ 00148 enum eRegionMode { 00149 Cube, /**< Cube */ 00150 Sphere /**< Sphere */ 00151 }; 00152 00153 /** 00154 * The original background color; default is black 00155 */ 00156 rgbPixel screenColor; 00157 00158 /** 00159 * Tolerance for the background color. 00160 * Size is half cube edge length, and sphere radius; default is 70. 00161 */ 00162 int size; 00163 00164 /** 00165 * Compute the tolerance in rgb-color-space based on a cube or a sphere 00166 * 00167 * default is "Cube" 00168 */ 00169 eRegionMode regionMode; 00170 00171 /** 00172 * Enable gauss filterin (slower but the edges in the result 00173 * look smoother) 00174 * 00175 * default is "true" 00176 */ 00177 bool gaussFilter; 00178 00179 /** 00180 * Kernel size for the gauss filter; default is 4 00181 */ 00182 int gaussKernelSize; 00183 00184 /** 00185 * The threshold value for gauss-filtered mask; default is 150 00186 */ 00187 int gaussMaskThreshold; 00188 00189 00190 }; 00191 00192 /** 00193 * default constructor 00194 */ 00195 blueScreen(); 00196 00197 /** 00198 * Construct a functor using the given parameters 00199 */ 00200 blueScreen(const parameters& par); 00201 00202 /** 00203 * copy constructor 00204 * @param other the object to be copied 00205 */ 00206 blueScreen(const blueScreen& other); 00207 00208 /** 00209 * destructor 00210 */ 00211 virtual ~blueScreen(); 00212 00213 /** 00214 * returns the name of this type ("blueScreen") 00215 */ 00216 virtual const char* getTypeName() const; 00217 00218 /** 00219 * operates on the given %parameter. 00220 * @param srcdest image with the source data. The result 00221 * will be left here too. 00222 * @param background: new background image 00223 * @return true if apply successful or false otherwise. 00224 */ 00225 bool apply(image& srcdest,image& background) const; 00226 00227 /** 00228 * operates on the given %parameter. 00229 * @param srcdest image with the source data. The result 00230 * will be left here too. 00231 * @param background: new background color 00232 * @return true if apply successful or false otherwise. 00233 */ 00234 bool apply(image& srcdest,rgbPixel& background) const; 00235 00236 /** 00237 * operates on a copy of the given %parameters. 00238 * @param src image with the source data. 00239 * @param dest image where the result will be left. 00240 * @param background: new background image 00241 * @return true if apply successful or false otherwise. 00242 */ 00243 bool apply(const image& src, 00244 image& dest, 00245 image& background) const; 00246 /** 00247 * operates on a copy of the given %parameters. 00248 * @param src image with the source data. 00249 * @param dest image where the result will be left. 00250 * @param background: new background color 00251 * @return true if apply successful or false otherwise. 00252 */ 00253 bool apply(const image& src, 00254 image& dest, 00255 rgbPixel& background) const; 00256 00257 /** 00258 * copy data of "other" functor. 00259 * @param other the functor to be copied 00260 * @return a reference to this functor object 00261 */ 00262 blueScreen& copy(const blueScreen& other); 00263 00264 /** 00265 * alias for copy member 00266 * @param other the functor to be copied 00267 * @return a reference to this functor object 00268 */ 00269 blueScreen& operator=(const blueScreen& other); 00270 00271 /** 00272 * returns a pointer to a clone of this functor. 00273 */ 00274 virtual functor* clone() const; 00275 00276 /** 00277 * returns used parameters 00278 */ 00279 const parameters& getParameters() const; 00280 00281 protected: 00282 /** 00283 * Checks if a given rgbPixel is in the defined cube-shaped area 00284 * in the rgb-color-space 00285 */ 00286 bool inCube(rgbPixel check) const; 00287 }; 00288 } 00289 00290 #endif