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 .......: lticomprehensiveColourNormalization.h 00027 * authors ....: Marius Wolf 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 19.3.2003 00030 * revisions ..: $Id: ltiComprehensiveColourNormalization.h,v 1.9 2006/02/07 18:39:39 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_COMPREHENSIVECOLOURNORMALIZATION_H_ 00034 #define _LTI_COMPREHENSIVECOLOURNORMALIZATION_H_ 00035 00036 #include "ltiColorNormalizationBase.h" 00037 00038 namespace lti { 00039 00040 /** 00041 * This class implements the algorithm described in the paper 00042 * "Comprehensive Colour Image Normalization" by Finlayson, Schiele 00043 * and Crowley. 00044 * 00045 * The original paper can be found here: 00046 * http://web.media.mit.edu/~bernt/Pubs/eccv98.ps.gz 00047 * 00048 * The algorithm can eliminate dependencies from lighting geometry and 00049 * illumination colour, normalizing both chromaticities and intensities of 00050 * each channel. 00051 */ 00052 class comprehensiveColourNormalization : public colorNormalizationBase { 00053 public: 00054 /** 00055 * the parameters for the class comprehensiveColourNormalization 00056 */ 00057 class parameters : public colorNormalizationBase::parameters { 00058 public: 00059 /** 00060 * default constructor 00061 */ 00062 parameters(); 00063 00064 /** 00065 * copy constructor 00066 * @param other the parameters object to be copied 00067 */ 00068 parameters(const parameters& other); 00069 00070 /** 00071 * destructor 00072 */ 00073 ~parameters(); 00074 00075 /** 00076 * returns name of this type 00077 */ 00078 const char* getTypeName() const; 00079 00080 /** 00081 * copy the contents of a parameters object 00082 * @param other the parameters object to be copied 00083 * @return a reference to this parameters object 00084 */ 00085 parameters& copy(const parameters& other); 00086 00087 /** 00088 * copy the contents of a parameters object 00089 * @param other the parameters object to be copied 00090 * @return a reference to this parameters object 00091 */ 00092 parameters& operator=(const parameters& other); 00093 00094 /** 00095 * returns a pointer to a clone of the parameters 00096 */ 00097 virtual functor::parameters* clone() const; 00098 00099 /** 00100 * write the parameters in the given ioHandler 00101 * @param handler the ioHandler to be used 00102 * @param complete if true (the default) the enclosing begin/end will 00103 * be also written, otherwise only the data block will be written. 00104 * @return true if write was successful 00105 */ 00106 virtual bool write(ioHandler& handler,const bool complete=true) const; 00107 00108 /** 00109 * read the parameters from the given ioHandler 00110 * @param handler the ioHandler to be used 00111 * @param complete if true (the default) the enclosing begin/end will 00112 * be also written, otherwise only the data block will be written. 00113 * @return true if write was successful 00114 */ 00115 virtual bool read(ioHandler& handler,const bool complete=true); 00116 00117 # ifdef _LTI_MSC_6 00118 /** 00119 * this function is required by MSVC only, as a workaround for a 00120 * very awful bug, which exists since MSVC V.4.0, and still by 00121 * V.6.0 with all bugfixes (so called "service packs") remains 00122 * there... This method is also public due to another bug, so please 00123 * NEVER EVER call this method directly: use read() instead 00124 */ 00125 bool readMS(ioHandler& handler,const bool complete=true); 00126 00127 /** 00128 * this function is required by MSVC only, as a workaround for a 00129 * very awful bug, which exists since MSVC V.4.0, and still by 00130 * V.6.0 with all bugfixes (so called "service packs") remains 00131 * there... This method is also public due to another bug, so please 00132 * NEVER EVER call this method directly: use write() instead 00133 */ 00134 bool writeMS(ioHandler& handler,const bool complete=true) const; 00135 # endif 00136 00137 // ------------------------------------------------ 00138 // the parameters 00139 // ------------------------------------------------ 00140 00141 /** 00142 * Maximum number of iterations done for an image. 00143 * 00144 * Default is 5. 00145 */ 00146 int maxSteps; 00147 00148 /** 00149 * Maximum square distance between the pixels of i-th and (i+1)-th image. 00150 * 00151 * When the maximum square euclidian distance between two pixels 00152 * of consecutive iterations falls below this value the process 00153 * is stopped. 00154 * 00155 * Possible values are between 0.0 and 3.0. These extreme values 00156 * are not very useful, however. 00157 * 00158 * Default: 1.0 00159 */ 00160 float maxDist; 00161 00162 }; 00163 00164 /** 00165 * default constructor 00166 */ 00167 comprehensiveColourNormalization(); 00168 00169 /** 00170 * Construct a functor using the given parameters 00171 */ 00172 comprehensiveColourNormalization(const parameters& par); 00173 00174 /** 00175 * copy constructor 00176 * @param other the object to be copied 00177 */ 00178 comprehensiveColourNormalization(const comprehensiveColourNormalization& other); 00179 00180 /** 00181 * destructor 00182 */ 00183 virtual ~comprehensiveColourNormalization(); 00184 00185 /** 00186 * returns the name of this type ("comprehensiveColourNormalization") 00187 */ 00188 virtual const char* getTypeName() const; 00189 00190 /** 00191 * operates on the given %parameter. 00192 * @param srcdest image with the source data. The result 00193 * will be left here too. 00194 * @return true if apply successful or false otherwise. 00195 */ 00196 virtual bool apply(image& srcdest) const; 00197 00198 /** 00199 * operates on a copy of the given %parameters. 00200 * @param src image with the source data. 00201 * @param dest image where the result will be left. 00202 * @return true if apply successful or false otherwise. 00203 */ 00204 virtual bool apply(const image& src,image& dest) const; 00205 00206 /** 00207 * copy data of "other" functor. 00208 * @param other the functor to be copied 00209 * @return a reference to this functor object 00210 */ 00211 comprehensiveColourNormalization& copy(const comprehensiveColourNormalization& other); 00212 00213 /** 00214 * alias for copy member 00215 * @param other the functor to be copied 00216 * @return a reference to this functor object 00217 */ 00218 comprehensiveColourNormalization& operator=(const comprehensiveColourNormalization& other); 00219 00220 /** 00221 * returns a pointer to a clone of this functor. 00222 */ 00223 virtual functor* clone() const; 00224 00225 /** 00226 * returns used parameters 00227 */ 00228 const parameters& getParameters() const; 00229 00230 protected: 00231 /** 00232 * One iteration of the comprehensive normalization from src to dest 00233 * 00234 * This method assumes that all channels are Connected 00235 * (see matrix::getMode()) 00236 * 00237 * The square of the maximum distance between the src and the dest channels 00238 * will be left on \a dist 00239 */ 00240 bool step(const channel& srcred, 00241 const channel& srcgreen, 00242 const channel& srcblue, 00243 channel& destred, 00244 channel& destgreen, 00245 channel& destblue, 00246 float& dist) const; 00247 00248 }; 00249 } 00250 00251 #endif