LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiHistogramEqualization.h

00001 /*
00002  * Copyright (C) 2000, 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 .......: ltiHistogramEqualization.h
00027  * authors ....: Thomas Erger
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 25.7.2000
00030  * revisions ..: $Id: ltiHistogramEqualization.h,v 1.9 2006/02/08 11:15:53 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_HISTOGRAM_EQUALIZATION_H_
00034 #define _LTI_HISTOGRAM_EQUALIZATION_H_
00035 
00036 #include "ltiObject.h"
00037 #include "ltiModifier.h"
00038 
00039 namespace lti {
00040   /**
00041    *  HistogramEqualization equalizes the values of the given channel,
00042    *  channel8, vector<ubyte> or fvector within the given input range and
00043    *  maps these equalized values to the given output range.
00044    *
00045    *  The algorithm used can be found in Sonka et. al "Image Processing,
00046    *  Analysis and Machine Vision" 2nd Edition, PWS Publishing, pp. 60-61
00047    *
00048    *  Example using HistogramEqualization
00049    *  \code
00050    *  // The channel to be equalized and the result channel
00051    *  lti::channel src,dest;
00052    *
00053    *  // ... initialize channel src here ...
00054    *
00055    *  // set parameters and construct the functor
00056    *  lti::histogramEqualization::parameters param;  // parameters
00057    *  param.cells = 256;           // cells
00058    *  param.lowerInputLimit=0.0;   // equalizes the dark values
00059    *  param.upperInputLimit=0.2;   //
00060    *  param.lowerOutputLimit=0.6;  // renders the equalized values lighter
00061    *  param.upperOutputLimit=1.0;  //
00062    *  lti::histogramEqualization equalizer(param);          // functor
00063    *
00064    *  // equalizes the values within input range, maps them to the output range
00065    *  // and returns the partly equalized channel in dest.
00066    *  equalizer.apply(src,dest);
00067    *  \endcode
00068    */
00069   class histogramEqualization : public modifier {
00070   public:
00071     /**
00072      * the parameters for the class histogramEqualization
00073      */
00074     class parameters : public modifier::parameters {
00075     public:
00076       /**
00077        * default constructor
00078        *
00079        * @param upperLimit upper value used for the input and output upper
00080        *                   limits.  It is 1.0f as default, but if you plan
00081        *                   to equalize channel8 objects, you should use 255
00082        */
00083       parameters(const float upperLimit=1.0f);
00084 
00085       /**
00086        * copy constructor
00087        * @param other the parameters object to be copied
00088        */
00089       parameters(const parameters& other);
00090 
00091       /**
00092        * destructor
00093        */
00094       ~parameters();
00095 
00096       /**
00097        * returns name of this type
00098        */
00099       const char* getTypeName() const;
00100 
00101       /**
00102        * copy the contents of a parameters object
00103        * @param other the parameters object to be copied
00104        * @return a reference to this parameters object
00105        */
00106       parameters& copy(const parameters& other);
00107 
00108       /**
00109        * returns a pointer to a clone of the parameters
00110        */
00111       virtual functor::parameters* clone() const;
00112 
00113       /**
00114        * write the parameters in the given ioHandler
00115        * @param handler the ioHandler to be used
00116        * @param complete if true (the default) the enclosing begin/end will
00117        *        be also written, otherwise only the data block will be written.
00118        * @return true if write was successful
00119        */
00120       virtual bool write(ioHandler& handler,const bool complete=true) const;
00121 
00122       /**
00123        * write the parameters in the given ioHandler
00124        * @param handler the ioHandler to be used
00125        * @param complete if true (the default) the enclosing begin/end will
00126        *        be also written, otherwise only the data block will be written.
00127        * @return true if write was successful
00128        */
00129       virtual bool read(ioHandler& handler,const bool complete=true);
00130 
00131 #     ifdef _LTI_MSC_6
00132       /**
00133        * this function is required by MSVC only, as a workaround for a
00134        * very awful bug, which exists since MSVC V.4.0, and still by
00135        * V.6.0 with all bugfixes (so called "service packs") remains
00136        * there...  This method is public due to another bug, so please
00137        * NEVER EVER call this method directly: use read() instead!
00138        */
00139       bool readMS(ioHandler& handler,const bool complete=true);
00140 
00141       /**
00142        * this function is required by MSVC only, as a workaround for a
00143        * very awful bug, which exists since MSVC V.4.0, and still by
00144        * V.6.0 with all bugfixes (so called "service packs") remains
00145        * there...  This method is public due to another bug, so please
00146        * NEVER EVER call this method directly: use write() instead!
00147        */
00148       bool writeMS(ioHandler& handler,const bool complete=true) const;
00149 #     endif
00150 
00151       // ------------------------------------------------
00152       // the parameters
00153       // ------------------------------------------------
00154 
00155       /**
00156        * the least value equalized.  Use values in the same input
00157        * range as the input parameter, i.e. values between 0.0 and 1.0
00158        * for channel equalization or values between 0 and 255 for
00159        * channel8 equalization. Default 0.0
00160        */
00161       float lowerInputLimit;
00162 
00163       /**
00164        * the least value the equalized values are mapped to.
00165        *
00166        * Use values in the same input range as the input parameter,
00167        * i.e. values between 0.0 and 1.0 for channel equalization or
00168        * values between 0 and 255 for channel8 equalization.
00169        * Default 0.0
00170        */
00171       float lowerOutputLimit;
00172 
00173       /**
00174        * the number of cells, the histogram uses for equalization
00175        *
00176        * Default 256
00177        */
00178       int cells;
00179 
00180       /**
00181        * the highest value equalized
00182        *
00183        * Use values in the same input range as the input parameter,
00184        * i.e. values between 0.0 and 1.0 for channel equalization or
00185        * values between 0 and 255 for channel8 equalization
00186        * Default 1.0
00187        */
00188       float upperInputLimit;
00189 
00190       /**
00191        * the highest value the equalized values are mapped to
00192        *
00193        * Use values in the same input range as the input parameter,
00194        * i.e. values between 0.0 and 1.0 for channel equalization or
00195        * values between 0 and 255 for channel8 equalization
00196        * Default 1.0
00197        */
00198       float upperOutputLimit;
00199     };
00200 
00201     /**
00202      * default constructor
00203      *
00204      * @param upperLimit upper value used for the input and output upper
00205      *                   limits.  It is 1.0f as default, but if you plan
00206      *                   to equalize channel8 objects, you should use 255
00207      */
00208     histogramEqualization(const float upperLimit=1.0f);
00209 
00210     /**
00211      * copy constructor
00212      * @param other the object to be copied
00213      */
00214     histogramEqualization(const histogramEqualization& other);
00215 
00216     /**
00217      * destructor
00218      */
00219     virtual ~histogramEqualization();
00220 
00221     /**
00222      * returns the name of this type ("histogramEqualization")
00223      * @return true if ok, false otherwise.
00224      */
00225     virtual const char* getTypeName() const;
00226 
00227     /**
00228      * equalizes the values of the given channel
00229      * @return true if ok, false otherwise.
00230      */
00231     bool apply(channel& srcdest) const;
00232 
00233     /**
00234      * equalizes the values of the given channel8
00235      * @return true if ok, false otherwise.
00236      */
00237     bool apply(channel8& srcdest) const;
00238 
00239     /**
00240      * equalizes the values of the given fvector
00241      * @return true if ok, false otherwise.
00242      */
00243     bool apply(fvector& srcdest) const;
00244 
00245     /**
00246      * equalizes the values of the given vector<ubyte>
00247      * @return true if ok, false otherwise.
00248      */
00249     bool apply(vector<ubyte>& srcdest) const;
00250 
00251     /**
00252      * returns the dest channel with equalized values of the src
00253      * channel
00254      * @param src the input data
00255      * @param dest the channel where the result will be left
00256      * @return true if ok, false otherwise.
00257      */
00258     bool apply(const channel& src,channel& dest) const;
00259 
00260     /**
00261      * returns the dest channel8 with equalized values of the src
00262      * channel8
00263      * @param src the input data
00264      * @param dest the channel8 where the result will be left
00265      * @return true if ok, false otherwise.
00266      */
00267     bool apply(const channel8& src,channel8& dest) const;
00268 
00269     /**
00270      * returns the dest fvector with equalized values of the src fvector
00271      * @param src the input data
00272      * @param dest the fvector where the result will be left
00273      * @return true if ok, false otherwise.
00274      */
00275     bool apply(const fvector& src,fvector& dest) const;
00276 
00277     /**
00278      * equalize the src vector and write result in dest
00279      * @param src the input data
00280      * @param dest the vector where the result will be left
00281      * @return true if ok, false otherwise.
00282      */
00283     bool apply(const vector<ubyte>& src,vector<ubyte>& dest) const;
00284 
00285     /**
00286      * copy data of "other" functor.
00287      * @param other the functor to be copied
00288      * @return a reference to this functor object
00289      */
00290     histogramEqualization& copy(const histogramEqualization& other);
00291 
00292     /**
00293      * returns a pointer to a clone of this functor.
00294      */
00295     virtual functor* clone() const;
00296 
00297     /**
00298      * returns used parameters
00299      */
00300     const parameters& getParameters() const;
00301 
00302   };
00303 
00304 }
00305 
00306 #endif

Generated on Sat Apr 10 15:25:37 2010 for LTI-Lib by Doxygen 1.6.1