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

ltiBrightRGB.h

00001 /*
00002  * Copyright (C) 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-Lib: Image Processing and Computer Vision Library
00026  * file .......: ltiBrightRGB.h
00027  * authors ....: Axel Berner
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 28.2.2002
00030  * revisions ..: $Id: ltiBrightRGB.h,v 1.9 2006/02/07 18:33:16 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_BRIGHT_R_G_B_H_
00034 #define _LTI_BRIGHT_R_G_B_H_
00035 
00036 #include "ltiGlobalFeatureExtractor.h"
00037 
00038 namespace lti {
00039   /**
00040    * This functor splits an image into its three channels (R.G,b) and
00041    * then calculates the Minimum, Maximum, Average, Median or Average
00042    * and Variance over their values, depending on the parameter type.
00043    *
00044    * It is possible to define a "transparent color" which will be
00045    * ignored by the calculation.
00046    */
00047   class brightRGB : public globalFeatureExtractor {
00048   public:
00049     /**
00050      * the parameters for the class brightRGB
00051      */
00052     class parameters : public globalFeatureExtractor::parameters {
00053     public:
00054 
00055       /**
00056        * Specification of the filter type used on each channel to
00057        * calculate the feature %vector. For all modes the transparent
00058        * color is not taken into account.
00059        * @see getMin()
00060        * @see getMax()
00061        * @see getAverage()
00062        * @see getMedian()
00063        */
00064       enum eBRGBFilterType {
00065         Minimum=0, /*!< find the minimum value of each channel */
00066         Maximum, /*!< find the maximum value of each channel */
00067         Average, /*!< find the average value of each channel */
00068         Median /*!< find the median of all values of each channel */
00069       };
00070 
00071       /**
00072        * default constructor
00073        */
00074       parameters();
00075 
00076       /**
00077        * copy constructor
00078        * @param other the parameters object to be copied
00079        */
00080       parameters(const parameters& other);
00081 
00082       /**
00083        * destructor
00084        */
00085       ~parameters();
00086 
00087       /**
00088        * returns name of this type
00089        */
00090       const char* getTypeName() const;
00091 
00092       /**
00093        * copy the contents of a parameters object
00094        * @param other the parameters object to be copied
00095        * @return a reference to this parameters object
00096        */
00097       parameters& copy(const parameters& other);
00098 
00099       /**
00100        * copy the contents of a parameters object
00101        * @param other the parameters object to be copied
00102        * @return a reference to this parameters object
00103        */
00104       parameters& operator=(const parameters& other);
00105 
00106 
00107       /**
00108        * returns a pointer to a clone of the parameters
00109        */
00110       virtual functor::parameters* clone() const;
00111 
00112       /**
00113        * write the parameters in the given ioHandler
00114        * @param handler the ioHandler to be used
00115        * @param complete if true (the default) the enclosing begin/end will
00116        *        be also written, otherwise only the data block will be written.
00117        * @return true if write was successful
00118        */
00119       virtual bool write(ioHandler& handler,const bool complete=true) const;
00120 
00121       /**
00122        * read the parameters from the given ioHandler
00123        * @param handler the ioHandler to be used
00124        * @param complete if true (the default) the enclosing begin/end will
00125        *        be also written, otherwise only the data block will be written.
00126        * @return true if write was successful
00127        */
00128       virtual bool read(ioHandler& handler,const bool complete=true);
00129 
00130 #     ifdef _LTI_MSC_6
00131       /**
00132        * this function is required by MSVC only, as a workaround for a
00133        * very awful bug, which exists since MSVC V.4.0, and still by
00134        * V.6.0 with all bugfixes (so called "service packs") remains
00135        * there...  This method is also public due to another bug, so please
00136        * NEVER EVER call this method directly: use read() instead
00137        */
00138       bool readMS(ioHandler& handler,const bool complete=true);
00139 
00140       /**
00141        * this function is required by MSVC only, as a workaround for a
00142        * very awful bug, which exists since MSVC V.4.0, and still by
00143        * V.6.0 with all bugfixes (so called "service packs") remains
00144        * there...  This method is also public due to another bug, so please
00145        * NEVER EVER call this method directly: use write() instead
00146        */
00147       bool writeMS(ioHandler& handler,const bool complete=true) const;
00148 #     endif
00149 
00150       // ------------------------------------------------
00151       // the parameters
00152       // ------------------------------------------------
00153 
00154       //TODO: comment the parameters of your functor
00155       // If you add more parameters manually, do not forget to do following:
00156       // 1. indicate in the default constructor the default values
00157       // 2. make sure that the copy member also copy your new parameters
00158       // 3. make sure that the read and write members also read and
00159       //    write your parameters
00160 
00161       /**
00162        * Kind of calculation rule used to get the values. Default value
00163        * is Average
00164        */
00165       eBRGBFilterType type;
00166 
00167       /**
00168        * define if there is a transparent color
00169        * i.e. is there a color to be ignored by the calculation
00170        * default value is true.
00171        */
00172       bool transparent;
00173 
00174       /**
00175        * color which will ignored by the calculation. Default value is
00176        * lti::Black.
00177        */
00178       rgbPixel transColor;
00179     };
00180 
00181     /**
00182      * default constructor
00183      */
00184     brightRGB();
00185 
00186     /**
00187      * copy constructor
00188      * @param other the object to be copied
00189      */
00190     brightRGB(const brightRGB& other);
00191 
00192     /**
00193      * destructor
00194      */
00195     virtual ~brightRGB();
00196 
00197     /**
00198      * returns the name of this type ("brightRGB")
00199      */
00200     virtual const char* getTypeName() const;
00201 
00202     /**
00203      * Calculates the Minimum, Maximum, Average or Median of each channel
00204      * of the given image, depending on the value of the parameter type.
00205      * @param src image which is analysed by the calculation rule
00206      * @param dest the result value per channel
00207      * @return true if apply successful or false otherwise.
00208      */
00209     bool apply(const image& src,dvector& dest) const;
00210 
00211     /**
00212      * copy data of "other" functor.
00213      * @param other the functor to be copied
00214      * @return a reference to this functor object
00215      */
00216     brightRGB& copy(const brightRGB& other);
00217 
00218     /**
00219      * alias for copy member
00220      * @param other the functor to be copied
00221      * @return a reference to this functor object
00222      */
00223     brightRGB& operator=(const brightRGB& other);
00224 
00225     /**
00226      * returns a pointer to a clone of this functor.
00227      */
00228     virtual functor* clone() const;
00229 
00230     /**
00231      * returns used parameters
00232      */
00233     const parameters& getParameters() const;
00234 
00235   protected:
00236     /**
00237      * Calculates the minimum value of each channel of the image.
00238      * If the %parameter transparent is true, the %transparent %color
00239      * defined by the %parameter transColor is not taken into account.
00240      * @param img image to be evaluated
00241      * @param dest vector with the minimum value of all not transparent points
00242      *             between R, G and B.
00243      * @return true if apply successful or false otherwise.
00244      */
00245     bool getMin(const image& img,dvector& dest) const;
00246 
00247    /**
00248      * Calculates the maximum value of each channel of the image.
00249      * If the %parameter transparent is true, the %transparent %color
00250      * defined by the %parameter transColor is not taken into account.
00251      * @param img image to be evaluated
00252      * @param dest vector with the maximum value of all not transparent points
00253      * between R, G and B.
00254      * @return true if apply successful or false otherwise.
00255      */
00256     bool getMax(const image& img,dvector& dest) const;
00257 
00258     /**
00259      * Calculates the average value of each channel of the image.
00260      * If the %parameter transparent is true, the %transparent %color
00261      * defined by the %parameter transColor is not taken into account.
00262      * @param img image to be evaluated
00263      * @param dest vector with the average value of all not
00264      * transparent points between R, G and B.
00265      * @return true if apply successful or false otherwise.
00266      */
00267     bool getAverage(const image& img,dvector& dest) const;
00268 
00269    /**
00270      * Calculates the median of all values of each channel of the image.
00271      * If the %parameter transparent is true, the %transparent %color
00272      * defined by the %parameter transColor is not taken into account.
00273      * @param img image to be evaluated
00274      * @param dest vector with the average value of all not transparent points
00275      *             between R, G and B.
00276      * @return true if apply successful or false otherwise.
00277      */
00278     bool getMedian(const image& img,dvector& dest) const;
00279   };
00280 }
00281 
00282 #endif

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