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 .......: ltiHistogramRGBL.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 14.5.2001 00030 * revisions ..: $Id: ltiHistogramRGBL.h,v 1.9 2006/02/08 11:16:13 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_HISTOGRAM_R_G_B_L_H_ 00034 #define _LTI_HISTOGRAM_R_G_B_L_H_ 00035 00036 #include "ltiImage.h" 00037 #include "ltiVector.h" 00038 #include "ltiLinearKernels.h" 00039 #include "ltiGlobalFeatureExtractor.h" 00040 00041 namespace lti { 00042 /** 00043 * This simple feature consists on four independently calculated histograms, 00044 * one for each color component R, G and B and the luminance L, defined as 00045 * L = (min(R,G,B) + max(R,G,B))/2. Each histogram contains the number of 00046 * cells given in the parameters, which means that the resulting 00047 * feature vector has a dimensionality of <code>4*cells</code>. 00048 */ 00049 class histogramRGBL : public globalFeatureExtractor { 00050 public: 00051 /** 00052 * the parameters for the class histogramRGBL 00053 */ 00054 class parameters : public globalFeatureExtractor::parameters { 00055 public: 00056 /** 00057 * default constructor 00058 */ 00059 parameters(); 00060 00061 /** 00062 * copy constructor 00063 * @param other the parameters object to be copied 00064 */ 00065 parameters(const parameters& other); 00066 00067 /** 00068 * destructor 00069 */ 00070 ~parameters(); 00071 00072 /** 00073 * returns name of this type 00074 */ 00075 const char* getTypeName() const; 00076 00077 /** 00078 * copy the contents of a parameters object 00079 * @param other the parameters object to be copied 00080 * @return a reference to this parameters object 00081 */ 00082 parameters& copy(const parameters& other); 00083 00084 /** 00085 * copy the contents of a parameters object 00086 * @param other the parameters object to be copied 00087 * @return a reference to this parameters object 00088 */ 00089 parameters& operator=(const parameters& other); 00090 00091 00092 /** 00093 * returns a pointer to a clone of the parameters 00094 */ 00095 virtual functor::parameters* clone() const; 00096 00097 /** 00098 * write the parameters in the given ioHandler 00099 * @param handler the ioHandler to be used 00100 * @param complete if true (the default) the enclosing begin/end will 00101 * be also written, otherwise only the data block will be written. 00102 * @return true if write was successful 00103 */ 00104 virtual bool write(ioHandler& handler,const bool complete=true) const; 00105 00106 /** 00107 * write the parameters in the given ioHandler 00108 * @param handler the ioHandler to be used 00109 * @param complete if true (the default) the enclosing begin/end will 00110 * be also written, otherwise only the data block will be written. 00111 * @return true if write was successful 00112 */ 00113 virtual bool read(ioHandler& handler,const bool complete=true); 00114 00115 # ifdef _LTI_MSC_6 00116 /** 00117 * this function is required by MSVC only, as a workaround for a 00118 * very awful bug, which exists since MSVC V.4.0, and still by 00119 * V.6.0 with all bugfixes (so called "service packs") remains 00120 * there... This method is also public due to another bug, so please 00121 * NEVER EVER call this method directly: use read() instead 00122 */ 00123 bool readMS(ioHandler& handler,const bool complete=true); 00124 00125 /** 00126 * this function is required by MSVC only, as a workaround for a 00127 * very awful bug, which exists since MSVC V.4.0, and still by 00128 * V.6.0 with all bugfixes (so called "service packs") remains 00129 * there... This method is also public due to another bug, so please 00130 * NEVER EVER call this method directly: use write() instead 00131 */ 00132 bool writeMS(ioHandler& handler,const bool complete=true) const; 00133 # endif 00134 00135 // ------------------------------------------------ 00136 // the parameters 00137 // ------------------------------------------------ 00138 00139 //TODO: comment the parameters of your functor 00140 // If you add more parameters manually, do not forget to do following: 00141 // 1. indicate in the default constructor the default values 00142 // 2. make sure that the copy member also copy your new parameters 00143 // 3. make sure that the read and write members also read and 00144 // write your parameters 00145 00146 00147 /** 00148 * If true, the resulting feature vector will be smothed using the given 00149 * filter kernel. 00150 * Default value: true 00151 */ 00152 bool smooth; 00153 00154 /** 00155 * smoothing kernel. 00156 * Default: gaussian kernel of size 3 (default variance). 00157 */ 00158 kernel1D<double> kernel; 00159 00160 /** 00161 * If true, the area under the each single histogram will be normalized 00162 * to one; i.e. the total area will be four. 00163 * Default value: true 00164 */ 00165 bool normalize; 00166 00167 /** 00168 * Number of cells per single color histogram. 00169 * The dimensionality of the resulting feature vector will be four times 00170 * this value. 00171 * Default value: 32 (i.e. 128 dimensions for the final feature vector) 00172 */ 00173 int cells; 00174 00175 /** 00176 * if true, the ignoreValue will be ignored and all data values will 00177 * be considered in the histogram generation. If false (the default) 00178 * all but the pixels with value <code>ignoreValue</code> will be 00179 * considered. 00180 * Default value: false 00181 */ 00182 bool considerAllData; 00183 00184 /** 00185 * this value will be ignored in the histogram. It is usually used 00186 * to ignore the background. 00187 * Default value (0,0,0), i.e. black will be ignored. 00188 */ 00189 rgbPixel ignoreValue; 00190 }; 00191 00192 /** 00193 * default constructor 00194 */ 00195 histogramRGBL(); 00196 00197 /** 00198 * copy constructor 00199 * @param other the object to be copied 00200 */ 00201 histogramRGBL(const histogramRGBL& other); 00202 00203 /** 00204 * destructor 00205 */ 00206 virtual ~histogramRGBL(); 00207 00208 /** 00209 * returns the name of this type ("histogramRGBL") 00210 */ 00211 virtual const char* getTypeName() const; 00212 00213 /** 00214 * operates on a copy of the given %parameters. 00215 * @param src image with the source data. 00216 * @param dest feature vector 00217 * @return true if apply successful or false otherwise. 00218 */ 00219 bool apply(const image& src,vector<double>& dest) const; 00220 00221 /** 00222 * copy data of "other" functor. 00223 * @param other the functor to be copied 00224 * @return a reference to this functor object 00225 */ 00226 histogramRGBL& copy(const histogramRGBL& other); 00227 00228 /** 00229 * returns a pointer to a clone of this functor. 00230 */ 00231 virtual functor* clone() const; 00232 00233 /** 00234 * returns used parameters 00235 */ 00236 const parameters& getParameters() const; 00237 }; 00238 } 00239 00240 #endif