latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiOpponentColor.h 00027 * authors ....: Axel Berner 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 7.8.2001 00030 * revisions ..: $Id: ltiOpponentColor.h,v 1.9 2007/01/10 02:26:00 alvarado Exp $ 00031 */ 00032 00033 #ifndef _LTI_OPPONENT_COLOR_H_ 00034 #define _LTI_OPPONENT_COLOR_H_ 00035 00036 #include "ltiTransform.h" 00037 #include "ltiImage.h" 00038 00039 namespace lti { 00040 /** 00041 * This functor generates an "opponent color" channel from the given two 00042 * channels, one representing the center, the other representing 00043 * the surround. 00044 * 00045 * The idea is to inhibit the response of a center region in a receptive 00046 * field with the responce of a surround region. 00047 * 00048 * \code 00049 * 00050 * 00051 * ________ 00052 * / \ 00053 * / ____ \ 00054 * | / \ | 00055 * | |Center| | 00056 * | \____/ | 00057 * \ Surround / 00058 * \________/ 00059 * 00060 * \endcode 00061 * 00062 * Usually, the surround pyramid-level is higher (lower resolution) 00063 * than the center, to simulate this consideration of a larger region 00064 * in the receptive field. 00065 * 00066 * Common used opponent color channels (Center-Surround) are the Red-Green, 00067 * Green-Red, Blue-Yellow, Yellow-Blue. But of course other combinations 00068 * can be employed (-Red+Green, etc.). 00069 * 00070 */ 00071 class opponentColor : public transform { 00072 public: 00073 /** 00074 * the parameters for the class opponentColor 00075 */ 00076 class parameters : public transform::parameters { 00077 public: 00078 /** 00079 * default constructor 00080 */ 00081 parameters(); 00082 00083 /** 00084 * copy constructor 00085 * @param other the parameters object to be copied 00086 */ 00087 parameters(const parameters& other); 00088 00089 /** 00090 * destructor 00091 */ 00092 ~parameters(); 00093 00094 /** 00095 * returns name of this type 00096 */ 00097 const char* getTypeName() const; 00098 00099 /** 00100 * copy the contents of a parameters object 00101 * @param other the parameters object to be copied 00102 * @return a reference to this parameters object 00103 */ 00104 parameters& copy(const parameters& other); 00105 00106 /** 00107 * copy the contents of a parameters object 00108 * @param other the parameters object to be copied 00109 * @return a reference to this parameters object 00110 */ 00111 parameters& operator=(const parameters& other); 00112 00113 /** 00114 * returns a pointer to a clone of the parameters 00115 */ 00116 virtual functor::parameters* clone() const; 00117 00118 /** 00119 * write the parameters in the given ioHandler 00120 * @param handler the ioHandler to be used 00121 * @param complete if true (the default) the enclosing begin/end will 00122 * be also written, otherwise only the data block will be written. 00123 * @return true if write was successful 00124 */ 00125 virtual bool write(ioHandler& handler,const bool complete=true) const; 00126 00127 /** 00128 * read the parameters from the given ioHandler 00129 * @param handler the ioHandler to be used 00130 * @param complete if true (the default) the enclosing begin/end will 00131 * be also written, otherwise only the data block will be written. 00132 * @return true if write was successful 00133 */ 00134 virtual bool read(ioHandler& handler,const bool complete=true); 00135 00136 # ifdef _LTI_MSC_6 00137 /** 00138 * this function is required by MSVC only, as a workaround for a 00139 * very awful bug, which exists since MSVC V.4.0, and still by 00140 * V.6.0 with all bugfixes (so called "service packs") remains 00141 * there... This method is also public due to another bug, so please 00142 * NEVER EVER call this method directly: use read() instead 00143 */ 00144 bool readMS(ioHandler& handler,const bool complete=true); 00145 00146 /** 00147 * this function is required by MSVC only, as a workaround for a 00148 * very awful bug, which exists since MSVC V.4.0, and still by 00149 * V.6.0 with all bugfixes (so called "service packs") remains 00150 * there... This method is also public due to another bug, so please 00151 * NEVER EVER call this method directly: use write() instead 00152 */ 00153 bool writeMS(ioHandler& handler,const bool complete=true) const; 00154 # endif 00155 00156 // ------------------------------------------------ 00157 // the parameters 00158 // ------------------------------------------------ 00159 00160 /** 00161 * defines the level of the GaussianPyramid for the center channel. 00162 * default: 0 00163 */ 00164 lti::ubyte centerLevel; 00165 00166 /** 00167 * Multiply factor for the center channel before adding to the opponent 00168 * channel (i.e. the sourround channel) 00169 * default: -1 00170 */ 00171 float centerSign; 00172 00173 /** 00174 * defines the level of the GaussianPyramid for the surround channel. 00175 * default: 1 00176 */ 00177 lti::ubyte surroundLevel; 00178 00179 /** 00180 * Multiply factor for the surround channel 00181 * before adding to the opponent channel (i.e. the center channel) 00182 * default: +1 00183 */ 00184 float surroundSign; 00185 00186 /** 00187 * Type to specify the way negative values should be considered. 00188 */ 00189 enum eFunctionType{ 00190 Normal, /**< linear condition, the negative values are keep as they 00191 are */ 00192 Abs, /**< absolute value, the negative values are multiplied with 00193 -1 */ 00194 Ramp /**< rectification, negative values are not allowed, and will 00195 be mapped to zero */ 00196 }; 00197 00198 /** 00199 * defines the handle with the negative values in the dest-image 00200 * Normal: no changes 00201 * Abs : absolute value 00202 * Ramp : values<0 to zero 00203 */ 00204 eFunctionType outFunc; 00205 00206 }; 00207 00208 /** 00209 * default constructor 00210 */ 00211 opponentColor(); 00212 00213 /** 00214 * copy constructor 00215 * @param other the object to be copied 00216 */ 00217 opponentColor(const opponentColor& other); 00218 00219 /** 00220 * destructor 00221 */ 00222 virtual ~opponentColor(); 00223 00224 /** 00225 * returns the name of this type ("opponentColor") 00226 */ 00227 virtual const char* getTypeName() const; 00228 00229 /** 00230 * Apply 00231 * 00232 * @param centerSrc channel with the source data. 00233 * @param surroundSrc channel with the source data. 00234 * @param dest channel where the result will be left. 00235 * @return true if apply successful or false otherwise. 00236 */ 00237 bool apply(const lti::channel& centerSrc, 00238 const lti::channel& surroundSrc, 00239 lti::channel& dest) const; 00240 00241 /* 00242 * standard-apply-method with parameter-handling 00243 * @param centerSrc channel with the source data. 00244 * @param surroundSrc channel with the source data. 00245 * @param dest channel where the result will be left. 00246 * @return true if apply successful or false otherwise. 00247 */ 00248 bool apply(const lti::channel& centerSrc, 00249 const lti::channel& surroundSrc, 00250 const int& centerLevel, 00251 const float& centerSign, 00252 const int& surroundLevel, 00253 const float& surroundSign, 00254 const parameters::eFunctionType& outFunc, 00255 lti::channel& dest) 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 opponentColor& copy(const opponentColor& other); 00263 00264 /** 00265 * returns a pointer to a clone of this functor. 00266 */ 00267 virtual functor* clone() const; 00268 00269 /** 00270 * returns used parameters 00271 */ 00272 const parameters& getParameters() const; 00273 }; 00274 } 00275 00276 #endif