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

ltiColorQuantization.h

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 .......: ltiColorQuantization.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 8.5.2001
00030  * revisions ..: $Id: ltiColorQuantization.h,v 1.7 2006/02/07 18:39:23 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_COLOR_QUANTIZATION_H_
00034 #define _LTI_COLOR_QUANTIZATION_H_
00035 
00036 
00037 #include "ltiFunctor.h"
00038 #include "ltiImage.h"
00039 #include "ltiVector.h"
00040 
00041 namespace lti {
00042 
00043   /**
00044    * Abstract parent class for all color quantization algorithms
00045    * All color quantization functors must overload the apply-member defined
00046    * here @see colorQuantization::apply.
00047    * The final quantize color image can be generated using the lti::usePalette
00048    * functor.
00049    */
00050   class colorQuantization : public functor {
00051   public:
00052     /**
00053      * the parameters for the class colorQuantization
00054      */
00055     class parameters : public functor::parameters {
00056     public:
00057       /**
00058        * default constructor
00059        */
00060       parameters();
00061 
00062       /**
00063        * copy constructor
00064        * @param other the parameters object to be copied
00065        */
00066       parameters(const parameters& other);
00067 
00068       /**
00069        * destructor
00070        */
00071       ~parameters();
00072 
00073       /**
00074        * returns name of this type
00075        */
00076       const char* getTypeName() const;
00077 
00078       /**
00079        * copy the contents of a parameters object
00080        * @param other the parameters object to be copied
00081        * @return a reference to this parameters object
00082        */
00083       parameters& copy(const parameters& other);
00084 
00085       /**
00086        * copy the contents of a parameters object
00087        * @param other the parameters object to be copied
00088        * @return a reference to this parameters object
00089        */
00090       parameters& operator=(const parameters& other);
00091 
00092 
00093       /**
00094        * returns a pointer to a clone of the parameters
00095        */
00096       virtual functor::parameters* clone() const;
00097 
00098       /**
00099        * write the parameters in the given ioHandler
00100        * @param handler the ioHandler to be used
00101        * @param complete if true (the default) the enclosing begin/end will
00102        *        be also written, otherwise only the data block will be written.
00103        * @return true if write was successful
00104        */
00105       virtual bool write(ioHandler& handler,const bool complete=true) const;
00106 
00107       /**
00108        * write the parameters in the given ioHandler
00109        * @param handler the ioHandler to be used
00110        * @param complete if true (the default) the enclosing begin/end will
00111        *        be also written, otherwise only the data block will be written.
00112        * @return true if write was successful
00113        */
00114       virtual bool read(ioHandler& handler,const bool complete=true);
00115 
00116 #     ifdef _LTI_MSC_6
00117       /**
00118        * this function is required by MSVC only, as a workaround for a
00119        * very awful bug, which exists since MSVC V.4.0, and still by
00120        * V.6.0 with all bugfixes (so called "service packs") remains
00121        * there...  This method is also public due to another bug, so please
00122        * NEVER EVER call this method directly: use read() instead
00123        */
00124       bool readMS(ioHandler& handler,const bool complete=true);
00125 
00126       /**
00127        * this function is required by MSVC only, as a workaround for a
00128        * very awful bug, which exists since MSVC V.4.0, and still by
00129        * V.6.0 with all bugfixes (so called "service packs") remains
00130        * there...  This method is also public due to another bug, so please
00131        * NEVER EVER call this method directly: use write() instead
00132        */
00133       bool writeMS(ioHandler& handler,const bool complete=true) const;
00134 #     endif
00135 
00136       // ------------------------------------------------
00137       // the parameters
00138       // ------------------------------------------------
00139 
00140       //TODO: comment the parameters of your functor
00141       // If you add more parameters manually, do not forget to do following:
00142       // 1. indicate in the default constructor the default values
00143       // 2. make sure that the copy member also copy your new parameters
00144       // 3. make sure that the read and write members also read and
00145       //    write your parameters
00146 
00147 
00148       /**
00149        * Number of colors that the resulting channel must have.
00150        * Usually this value must be between 2 and 256, but each functor
00151        * can modify this requirement.  Default value: 256
00152        */
00153       int numberOfColors;
00154 
00155     };
00156 
00157     /**
00158      * default constructor
00159      */
00160     colorQuantization();
00161 
00162     /**
00163      * copy constructor
00164      * @param other the object to be copied
00165      */
00166     colorQuantization(const colorQuantization& other);
00167 
00168     /**
00169      * destructor
00170      */
00171     virtual ~colorQuantization();
00172 
00173     /**
00174      * returns the name of this type ("colorQuantization")
00175      */
00176     virtual const char* getTypeName() const;
00177 
00178     /**
00179      * operates on a copy of the given %parameters.
00180      * @param src original image with the true-color data
00181      * @param dest channel8 where the indexes of the also calculated palette
00182      *             will be.
00183      * @param thePalette the color palette used by the channel.
00184      * @return true if apply successful or false otherwise.
00185      */
00186     virtual bool apply(const image& src,
00187                        channel8& dest,
00188                        palette& thePalette) const = 0;
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 the given %parameter.
00200      * @param src image with the source data.
00201      * @param dest image with only the number of colors specified in
00202      *             the parameters
00203      * @return true if apply successful or false otherwise.
00204      */
00205     virtual bool apply(const image& src,image& dest) const;
00206 
00207     /**
00208      * copy data of "other" functor.
00209      * @param other the functor to be copied
00210      * @return a reference to this functor object
00211      */
00212     colorQuantization& copy(const colorQuantization& other);
00213 
00214     /**
00215      * returns a pointer to a clone of this functor.
00216      */
00217     virtual functor* clone() const = 0;
00218 
00219     /**
00220      * returns used parameters
00221      */
00222     const parameters& getParameters() const;
00223   };
00224 }
00225 
00226 #endif

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