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

ltiBinarizationCodec.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 .......: ltiBinarizationCodec.h
00027  * authors ....: Jochen Wickel
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 5.11.2002
00030  * revisions ..: $Id: ltiBinarizationCodec.h,v 1.5 2006/02/08 12:01:22 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_BINARIZATION_CODEC_H_
00034 #define _LTI_BINARIZATION_CODEC_H_
00035 
00036 #include "ltiDataCodec.h"
00037 
00038 namespace lti {
00039   /**
00040    * Encodes a byte array to an array of bits. In the encoded array, each
00041    * bit will represent a byte in the original array.
00042    */
00043   class binarizationCodec : public dataCodec {
00044   public:
00045 
00046     /**
00047      * The parameters for the class binarizationCodec.
00048      */
00049     class parameters : public dataCodec::parameters {
00050     public:
00051       /**
00052        * default constructor
00053        */
00054       parameters();
00055 
00056       /**
00057        * copy constructor
00058        * @param other the parameters object to be copied
00059        */
00060       parameters(const parameters& other);
00061 
00062       /**
00063        * destructor
00064        */
00065       ~parameters();
00066 
00067       /**
00068        * returns name of this type
00069        */
00070       const char* getTypeName() const;
00071 
00072       /**
00073        * copy the contents of a parameters object
00074        * @param other the parameters object to be copied
00075        * @return a reference to this parameters object
00076        */
00077       parameters& copy(const parameters& other);
00078 
00079       /**
00080        * copy the contents of a parameters object
00081        * @param other the parameters object to be copied
00082        * @return a reference to this parameters object
00083        */
00084       parameters& operator=(const parameters& other);
00085 
00086 
00087       /**
00088        * returns a pointer to a clone of the parameters
00089        */
00090       virtual functor::parameters* clone() const;
00091 
00092       /**
00093        * write the parameters in the given ioHandler
00094        * @param handler the ioHandler to be used
00095        * @param complete if true (the default) the enclosing begin/end will
00096        *        be also written, otherwise only the data block will be written.
00097        * @return true if write was successful
00098        */
00099       virtual bool write(ioHandler& handler,const bool complete=true) const;
00100 
00101       /**
00102        * read the parameters from the given ioHandler
00103        * @param handler the ioHandler to be used
00104        * @param complete if true (the default) the enclosing begin/end will
00105        *        be also written, otherwise only the data block will be written.
00106        * @return true if write was successful
00107        */
00108       virtual bool read(ioHandler& handler,const bool complete=true);
00109 
00110 #     ifdef _LTI_MSC_6
00111       /**
00112        * this function is required by MSVC only, as a workaround for a
00113        * very awful bug, which exists since MSVC V.4.0, and still by
00114        * V.6.0 with all bugfixes (so called "service packs") remains
00115        * there...  This method is also public due to another bug, so please
00116        * NEVER EVER call this method directly: use read() instead
00117        */
00118       bool readMS(ioHandler& handler,const bool complete=true);
00119 
00120       /**
00121        * this function is required by MSVC only, as a workaround for a
00122        * very awful bug, which exists since MSVC V.4.0, and still by
00123        * V.6.0 with all bugfixes (so called "service packs") remains
00124        * there...  This method is also public due to another bug, so please
00125        * NEVER EVER call this method directly: use write() instead
00126        */
00127       bool writeMS(ioHandler& handler,const bool complete=true) const;
00128 #     endif
00129 
00130       // ------------------------------------------------
00131       // the parameters
00132       // ------------------------------------------------
00133 
00134       //TODO: comment the parameters of your functor
00135       // If you add more parameters manually, do not forget to do following:
00136       // 1. indicate in the default constructor the default values
00137       // 2. make sure that the copy member also copy your new parameters
00138       // 3. make sure that the read and write members also read and
00139       //    write your parameters
00140 
00141       /**
00142        * The threshold above which elements are encoded to "1".
00143        */
00144       bufferElement threshold;
00145 
00146       /**
00147        * The value to which "1" is decoded.
00148        */
00149       bufferElement maxValue;
00150     };
00151 
00152     /**
00153      * default constructor
00154      */
00155     binarizationCodec();
00156 
00157     /**
00158      * Construct a functor using the given parameters
00159      */
00160     binarizationCodec(const parameters& par);
00161 
00162     /**
00163      * copy constructor
00164      * @param other the object to be copied
00165      */
00166     binarizationCodec(const binarizationCodec& other);
00167 
00168     /**
00169      * destructor
00170      */
00171     virtual ~binarizationCodec();
00172 
00173     /**
00174      * returns the name of this type ("binarizationCodec")
00175      */
00176     virtual const char* getTypeName() const;
00177 
00178     /**
00179      * returns used parameters
00180      */
00181     const parameters& getParameters() const;
00182 
00183     /**
00184      * copy data of "other" functor.
00185      * @param other the functor to be copied
00186      * @return a reference to this functor object
00187      */
00188     binarizationCodec& copy(const binarizationCodec& other);
00189 
00190     /**
00191      * alias for copy member
00192      * @param other the functor to be copied
00193      * @return a reference to this functor object
00194      */
00195     binarizationCodec& operator=(const binarizationCodec& other);
00196 
00197     /**
00198      * returns a pointer to a clone of this functor.
00199      */
00200     virtual functor* clone() const;
00201 
00202     //TODO: comment the attributes of your functor
00203     // If you add more attributes manually, do not forget to do following:
00204     // 1. indicate in the default constructor the default values
00205     // 2. make sure that the copy member also copy your new attributes, or
00206     //    to ensure there, that these attributes are properly initialized.
00207 
00208 
00209     /**
00210      * Computes the default buffer size for encoded data. The
00211      * source of the original data buffer is given as argument.
00212      * The default is to return the given value.
00213      * @param originalSize the size of the data buffer to be encoded
00214      * @return the estimated size of the encoded data.
00215      */
00216     virtual int estimateEncodedSize(int originalSize) const;
00217 
00218     /**
00219      * Computes the default buffer size for decoded data. The
00220      * source of the original data buffer is given as argument.
00221      * The default is to return the given value.
00222      * @param originalSize the size of the data buffer to be decoded
00223      * @return the estimated size of the encoded data.
00224      */
00225     virtual int estimateDecodedSize(int originalSize) const;
00226 
00227   protected:
00228     //TODO: comment your apply methods!
00229 
00230     virtual bool decodeImplementation(const buffer& src, buffer& dest,
00231                                       int nsrc,  int& ndest) const;
00232 
00233     virtual bool encodeImplementation(const buffer& src, buffer& dest,
00234                                       int nsrc, int& ndest) const;
00235 
00236 
00237   };
00238 }
00239 
00240 #endif

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