latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiRelativeThresholding.h 00027 * authors ....: Arnd Hannemann 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 4.1.2004 00030 * revisions ..: $Id: ltiRelativeThresholding.h,v 1.8 2006/02/08 11:46:26 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_RELATIVE_THRESHOLDING_H_ 00034 #define _LTI_RELATIVE_THRESHOLDING_H_ 00035 00036 #include "ltiThresholding.h" 00037 00038 namespace lti { 00039 /** 00040 * This class implements percentual Thresholding. 00041 * The parameter values highThreshold and lowThreshold inherited from 00042 * thresholding::parameters are interpreted as percentages. 00043 * i.e. lowThreshold = 0.5f means that approximately the lower 50% of the 00044 * pixels will be cut off. 00045 * 00046 * It uses a simple histogramm with thresholding::parameters::bins 00047 * to calculate the absolute thresholds. 00048 * 00049 * \code 00050 * #include ltiRelativeThresholding.h 00051 * 00052 * lti::relativeThresholding::parameters rtPar; 00053 * rtPar.lowThreshold = 0.5f; 00054 * // creates a black&white mask 00055 * rtPar.outRegionValue = 0.0f; 00056 * rtPar.inRegionValue = 1.0f; 00057 * rtPar.keepInRegion = false; 00058 * 00059 * lti::relativeThresholding rt(rtPar); 00060 * rt.apply(sourcechannel,destchannel); 00061 * \endcode 00062 */ 00063 class relativeThresholding : public thresholding { 00064 public: 00065 /** 00066 * the parameters for the class relativeThresholding 00067 */ 00068 class parameters : public thresholding::parameters { 00069 public: 00070 /** 00071 * default constructor 00072 */ 00073 parameters(); 00074 00075 /** 00076 * copy constructor 00077 * @param other the parameters object to be copied 00078 */ 00079 parameters(const parameters& other); 00080 00081 /** 00082 * destructor 00083 */ 00084 ~parameters(); 00085 00086 /** 00087 * returns name of this type 00088 */ 00089 const char* getTypeName() const; 00090 00091 /** 00092 * copy the contents of a parameters object 00093 * @param other the parameters object to be copied 00094 * @return a reference to this parameters object 00095 */ 00096 parameters& copy(const parameters& other); 00097 00098 /** 00099 * copy the contents of a parameters object 00100 * @param other the parameters object to be copied 00101 * @return a reference to this parameters object 00102 */ 00103 parameters& operator=(const parameters& other); 00104 00105 00106 /** 00107 * returns a pointer to a clone of the parameters 00108 */ 00109 virtual functor::parameters* clone() const; 00110 00111 /** 00112 * write the parameters in the given ioHandler 00113 * @param handler the ioHandler to be used 00114 * @param complete if true (the default) the enclosing begin/end will 00115 * be also written, otherwise only the data block will be written. 00116 * @return true if write was successful 00117 */ 00118 virtual bool write(ioHandler& handler,const bool complete=true) const; 00119 00120 /** 00121 * read the parameters from the given ioHandler 00122 * @param handler the ioHandler to be used 00123 * @param complete if true (the default) the enclosing begin/end will 00124 * be also written, otherwise only the data block will be written. 00125 * @return true if write was successful 00126 */ 00127 virtual bool read(ioHandler& handler,const bool complete=true); 00128 00129 # ifdef _LTI_MSC_6 00130 /** 00131 * this function is required by MSVC only, as a workaround for a 00132 * very awful bug, which exists since MSVC V.4.0, and still by 00133 * V.6.0 with all bugfixes (so called "service packs") remains 00134 * there... This method is also public due to another bug, so please 00135 * NEVER EVER call this method directly: use read() instead 00136 */ 00137 bool readMS(ioHandler& handler,const bool complete=true); 00138 00139 /** 00140 * this function is required by MSVC only, as a workaround for a 00141 * very awful bug, which exists since MSVC V.4.0, and still by 00142 * V.6.0 with all bugfixes (so called "service packs") remains 00143 * there... This method is also public due to another bug, so please 00144 * NEVER EVER call this method directly: use write() instead 00145 */ 00146 bool writeMS(ioHandler& handler,const bool complete=true) const; 00147 # endif 00148 00149 // ------------------------------------------------ 00150 // the parameters 00151 // ------------------------------------------------ 00152 00153 /** 00154 * How many bins are used in the histogramm which is used 00155 * used to calculate absolute thresholds. 00156 * 00157 * Default: 256 00158 */ 00159 int bins; 00160 00161 }; 00162 00163 /** 00164 * default constructor 00165 */ 00166 relativeThresholding(); 00167 00168 /** 00169 * Construct a functor using the given parameters 00170 */ 00171 relativeThresholding(const parameters& par); 00172 00173 /** 00174 * copy constructor 00175 * @param other the object to be copied 00176 */ 00177 relativeThresholding(const relativeThresholding& other); 00178 00179 /** 00180 * destructor 00181 */ 00182 virtual ~relativeThresholding(); 00183 00184 /** 00185 * returns the name of this type ("relativeThresholding") 00186 */ 00187 virtual const char* getTypeName() const; 00188 00189 /** 00190 * operates on the given %parameter. 00191 * @param srcdest channel with the source data. The result 00192 * will be left here too. 00193 * @return true if apply successful or false otherwise. 00194 */ 00195 bool apply(channel& srcdest) const; 00196 00197 /** 00198 * operates on the given %parameter. 00199 * @param srcdest channel8 with the source data. The result 00200 * will be left here too. 00201 * @return true if apply successful or false otherwise. 00202 */ 00203 bool apply(channel8& srcdest) const; 00204 00205 /** 00206 * operates on a copy of the given %parameters. 00207 * @param src channel with the source data. 00208 * @param dest channel where the result will be left. 00209 * @return true if apply successful or false otherwise. 00210 */ 00211 bool apply(const channel& src,channel& dest) const; 00212 00213 /** 00214 * operates on a copy of the given %parameters. 00215 * @param src channel8 with the source data. 00216 * @param dest channel8 where the result will be left. 00217 * @return true if apply successful or false otherwise. 00218 */ 00219 bool apply(const channel8& src,channel8& 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 relativeThresholding& copy(const relativeThresholding& other); 00227 00228 /** 00229 * alias for copy member 00230 * @param other the functor to be copied 00231 * @return a reference to this functor object 00232 */ 00233 relativeThresholding& operator=(const relativeThresholding& other); 00234 00235 /** 00236 * returns a pointer to a clone of this functor. 00237 */ 00238 virtual functor* clone() const; 00239 00240 /** 00241 * returns used parameters 00242 */ 00243 const parameters& getParameters() const; 00244 00245 }; 00246 } 00247 00248 #endif