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 .......: ltiHistograming1D.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 12.4.2001 00030 * revisions ..: $Id: ltiHistograming1D.h,v 1.10 2006/02/08 11:16:31 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_HISTOGRAMING1_D_H_ 00034 #define _LTI_HISTOGRAMING1_D_H_ 00035 00036 00037 #include "ltiGlobalFeatureExtractor.h" 00038 #include "ltiLinearKernels.h" 00039 #include "ltiHistogram.h" 00040 #include "ltiVector.h" 00041 00042 namespace lti { 00043 /** 00044 * This class extracts a 1D histogram from a channel or channel8. 00045 * The result can be a lti::histogram1D or a lti::vector<double>, which is 00046 * the standard type for feature vectors. 00047 * It is possible to apply a smoothing filter to the extracted histogram 00048 */ 00049 class histograming1D : public globalFeatureExtractor { 00050 public: 00051 /** 00052 * the parameters for the class histograming1D 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 * returns a pointer to a clone of the parameters 00093 */ 00094 virtual functor::parameters* clone() const; 00095 00096 /** 00097 * write the parameters in the given ioHandler 00098 * @param handler the ioHandler to be used 00099 * @param complete if true (the default) the enclosing begin/end will 00100 * be also written, otherwise only the data block will be written. 00101 * @return true if write was successful 00102 */ 00103 virtual bool write(ioHandler& handler,const bool complete=true) const; 00104 00105 /** 00106 * write the parameters in the given ioHandler 00107 * @param handler the ioHandler to be used 00108 * @param complete if true (the default) the enclosing begin/end will 00109 * be also written, otherwise only the data block will be written. 00110 * @return true if write was successful 00111 */ 00112 virtual bool read(ioHandler& handler,const bool complete=true); 00113 00114 # ifdef _LTI_MSC_6 00115 /** 00116 * this function is required by MSVC only, as a workaround for a 00117 * very awful bug, which exists since MSVC V.4.0, and still by 00118 * V.6.0 with all bugfixes (so called "service packs") remains 00119 * there... This method is also public due to another bug, so please 00120 * NEVER EVER call this method directly: use read() instead 00121 */ 00122 bool readMS(ioHandler& handler,const bool complete=true); 00123 00124 /** 00125 * this function is required by MSVC only, as a workaround for a 00126 * very awful bug, which exists since MSVC V.4.0, and still by 00127 * V.6.0 with all bugfixes (so called "service packs") remains 00128 * there... This method is also public due to another bug, so please 00129 * NEVER EVER call this method directly: use write() instead 00130 */ 00131 bool writeMS(ioHandler& handler,const bool complete=true) const; 00132 # endif 00133 00134 // ------------------------------------------------ 00135 // the parameters 00136 // ------------------------------------------------ 00137 00138 // If you add more parameters manually, do not forget to do following: 00139 // 1. indicate in the default constructor the default values 00140 // 2. make sure that the copy member also copy your new parameters 00141 // 3. make sure that the read and write members also read and 00142 // write your parameters 00143 00144 00145 /** 00146 * The smoothing kernel. 00147 * Default value: the default gaussian kernel of size 3 00148 */ 00149 kernel1D<double> kernel; 00150 00151 /** 00152 * smooth specify if the kernel should be apply at the end of the 00153 * histograming. 00154 * Default value: false 00155 */ 00156 bool smooth; 00157 00158 /** 00159 * Number of cells in the histogram. 00160 * Default: 256 00161 */ 00162 int cells; 00163 00164 /** 00165 * type to specify the mode of histogram 00166 */ 00167 enum eMode { 00168 Normal, /**< the histogram will be calculated between 0 and 1.0 for 00169 channels or between 0 and 255 for channel8s. Values 00170 under 0 will be assigned to 0 and values above 1.0 (or 255) 00171 will be assigned to the <code>cells-1</code> cell. 00172 The <code>ignoreValue</code> allows to ignore one specific 00173 value in this interval (usually used to ignore background 00174 */ 00175 Extremes, /**< the histogram will be calculated between the min and 00176 max values of the input data */ 00177 Interval /**< the histogram will be calculated between the given 00178 interval values. Note that the given values will 00179 be interpreted "as is", for example if you give as 00180 interval 0-1.0, the whole channel value range will 00181 be histogramed, but only two values of channel8 will 00182 be considered!. Only the values in the interval will 00183 be considered, i.e. elements outside the interval will 00184 be ignored. */ 00185 }; 00186 00187 /** 00188 * the mode of histograming (see eMode). 00189 * If the mode is "Normal", the outliers will be considered as part of 00190 * the nearest cell. (for example if using a channel, and the value of a 00191 * pixel is -0.1 the cell 0 will be incremented). 00192 * Default value: Normal 00193 */ 00194 eMode mode; 00195 00196 /** 00197 * if true, the histogram will be normalized (to have an area of 1) 00198 * Default: false 00199 */ 00200 bool normalize; 00201 00202 /** 00203 * if mode==Interval, this is the lowest value considered 00204 * (Default 0.0f) 00205 */ 00206 float intervalLow; 00207 00208 /** 00209 * if mode==Interval, this is the highest value to be considered 00210 * (Default 1.0f) 00211 */ 00212 float intervalHigh; 00213 00214 /** 00215 * this value will be ignored (Default -1.0f) 00216 */ 00217 float ignoreValue; 00218 }; 00219 00220 /** 00221 * default constructor 00222 */ 00223 histograming1D(); 00224 00225 /** 00226 * Construct with given parameters 00227 */ 00228 histograming1D(const parameters& par); 00229 00230 /** 00231 * copy constructor 00232 * @param other the object to be copied 00233 */ 00234 histograming1D(const histograming1D& other); 00235 00236 /** 00237 * destructor 00238 */ 00239 virtual ~histograming1D(); 00240 00241 /** 00242 * returns the name of this type ("histograming1D") 00243 */ 00244 virtual const char* getTypeName() const; 00245 00246 /** 00247 * generates feature vector for the src channel, and leaves the result 00248 * in the dest vector 00249 * @param src channel with the source data. 00250 * @param dest dvector where the result will be left. 00251 * @return true if successful, false otherwise. 00252 */ 00253 virtual bool apply(const channel& src,dvector& dest) const; 00254 00255 /** 00256 * generates feature vector for the src channel, and leaves the result 00257 * in the dest vector 00258 * @param src channel8 with the source data. 00259 * @param dest vector<double> where the result will be left. 00260 * @return true if successful, false otherwise. 00261 */ 00262 virtual bool apply(const channel8& src,dvector& dest) const; 00263 00264 /** 00265 * generates feature vector for the src channel, and leaves the result 00266 * in the dest vector 00267 * @param src channel with the source data. 00268 * @param dest dvector where the result will be left. 00269 * @return true if successful, false otherwise. 00270 */ 00271 virtual bool apply(const channel& src,histogram1D& dest) const; 00272 00273 /** 00274 * generates feature vector for the src channel, and leaves the result 00275 * in the dest vector 00276 * @param src channel8 with the source data. 00277 * @param dest vector<double> where the result will be left. 00278 * @return true if successful, false otherwise. 00279 */ 00280 virtual bool apply(const channel8& src,histogram1D& dest) const; 00281 00282 /** 00283 * copy data of "other" functor. 00284 * @param other the functor to be copied 00285 * @return a reference to this functor object 00286 */ 00287 histograming1D& copy(const histograming1D& other); 00288 00289 /** 00290 * returns a pointer to a clone of this functor. 00291 */ 00292 virtual functor* clone() const; 00293 00294 /** 00295 * returns used parameters 00296 */ 00297 const parameters& getParameters() const; 00298 }; 00299 } 00300 00301 #endif