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

ltiPyramid.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 .......: ltiPyramid.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 30.10.00
00030  * revisions ..: $Id: ltiPyramid.h,v 1.5 2006/02/08 11:20:15 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_PYRAMID_H_
00034 #define _LTI_PYRAMID_H_
00035 
00036 #include "ltiVector.h"
00037 #include "ltiMatrix.h"
00038 
00039 namespace lti {
00040   /**
00041    * Pyramid class.
00042    *
00043    * The lti::pyramid class is the parent class for the multiresolutional
00044    * pyramids.  For example lti::gaussianPyramid
00045    *
00046    * It contains some objects of type T (e.g. channel, channel8 or image),
00047    * which must implement the type T::size_type and the member size().  Note
00048    * that pyramids of pyramids are allowed.
00049    *
00050    */
00051   template <class T>
00052   class pyramid : public mathObject {
00053   public:
00054 
00055     /**
00056      * The iterator is equivalent to a lti::fvector::iterator
00057      */
00058     typedef typename std::vector<T>::iterator iterator;
00059 
00060     /**
00061      * The const_iterator is equivalent to a lti::fvector::const_iterator
00062      */
00063     typedef typename std::vector<T>::const_iterator const_iterator;
00064 
00065     /**
00066      * Default constructor creates an empty pyramid;
00067      */
00068     pyramid();
00069 
00070     /**
00071      * Create a pyramid with the given number of resolutions or scales
00072      *
00073      * @param resolutions the number of resolutions or scales in the pyramid
00074      */
00075     pyramid(const int& resolutions);
00076 
00077     /**
00078      * Create this pyramid as a copy of another pyramid
00079      * @param other the pyramid to be copied.
00080      */
00081     pyramid(const pyramid& other);
00082 
00083     /**
00084      * Destructor
00085      */
00086     virtual ~pyramid();
00087 
00088     /**
00089      * Returns the name of this class: "pyramid"
00090      */
00091     const char* getTypeName() const {return "pyramid";};
00092 
00093     /**
00094      * The return type of the size() member
00095      */
00096     typedef int size_type;
00097 
00098     /**
00099      * Returns the number of resolutions of this pyramid
00100      */
00101     inline int size() const;
00102 
00103     /**
00104      * Returns true if the size of this pyramid is zero.
00105      */
00106     inline bool empty() const;
00107 
00108     /**
00109      * Returns an iterator pointing to the first element.
00110      * Note that you can not change the values of the pyramid
00111      * elements when you use a const_iterator. See also begin()
00112      */
00113     inline const_iterator begin() const;
00114 
00115     /**
00116      * Returns an iterator pointing to the first element.
00117      * The use of the interators is similar to the iterators of the
00118      * Standard Template Library (STL).
00119      */
00120     inline iterator begin();
00121 
00122     /**
00123      * Returns last index as a const iterator.
00124      * For an example see begin()
00125      */
00126     inline const_iterator end() const;
00127 
00128     /**
00129      * Returns last index as an iterator
00130      * For an example see begin()
00131      */
00132     inline iterator end();
00133 
00134     /**
00135      * Change the number of resolutions of the pyramid
00136      *
00137      * @param resolutions the new number of resolutions of the pyramid
00138      * @param copyData if true (default), the old data will be keeped.
00139      *                 If false, all data will be lost.
00140      */
00141     virtual void resize(const int& resolutions,
00142       const bool& copyData=true);
00143 
00144     /**
00145      * Append one element to the pyramid
00146      *
00147      * @param theElement Element that will be appended to the pyramid
00148      */
00149     void append(const T& theElement);
00150 
00151     /**
00152      * Equivalent to resize(0);
00153      */
00154     void clear();
00155 
00156     /**
00157      * Read-only access to the element x of the pyramid
00158      * @param x index of the pyramid element to be accessed.  It should
00159      *          be between 0 and size()-1
00160      * @return the number of entries in the given cell
00161      */
00162     inline const T& at(const int& x) const;
00163 
00164     /**
00165      * Access element x of the pyramid
00166      * @param x index of the pyramid element to be accessed.  It should
00167      *          be between 0 and size()-1
00168      * @return the number of entries in the given cell
00169      */
00170     inline T& at(const int& x);
00171 
00172     /**
00173      * Read-only access to the element x of the pyramid
00174      * @param x index of the pyramid element to be accessed.  It should
00175      *          be between 0 and size()-1
00176      * @return the number of entries in the given cell
00177      */
00178     inline const T& operator[](const int& x) const;
00179 
00180     /**
00181      * Access element x of the pyramid
00182      * @param x index of the pyramid element to be accessed.  It should
00183      *          be between 0 and size()-1
00184      * @return the number of entries in the given cell
00185      */
00186     inline T& operator[](const int& x);
00187 
00188 
00189     /**
00190      * Assigment operator.
00191      * copy the contents of <code>other</code> in this %object.
00192      * @param other the source pyramid to be copied.
00193      * @return a reference to this object
00194      */
00195     pyramid<T>& copy(const pyramid<T>& other);
00196 
00197     /**
00198      * Create a clone of this pyramid
00199      * @return a pointer to a copy of this pyramid
00200      */
00201     virtual mathObject* clone() const;
00202 
00203     /**
00204      * Compare this pyramid with another one.
00205      *
00206      * @param other the other pyramid to be compared with
00207      * @return true if both pyramids have the same elements and same size
00208      */
00209     bool equals(const pyramid& other) const;
00210 
00211     /**
00212      * Compare if the resolutions of this and the other pyramid are the same.
00213      * @param other the pyramid to be compared with.
00214      * @return true if both pyramids and its elements have the same size
00215      */
00216     bool compareResolutions(const pyramid& other) const;
00217 
00218     /**
00219      * Compare this pyramid with another one
00220      *
00221      * @param other the other pyramid to be compared with
00222      * @return true if both pyramids have the same elements and same size
00223      */
00224     inline bool operator==(const pyramid& other) const {
00225       return equals(other);
00226     };
00227 
00228     /**
00229      * Assigment operator (alias for copy(other)).
00230      * @param other the pyramid to be copied
00231      * @return a reference to the actual pyramid
00232      */
00233     inline pyramid& operator=(const pyramid& other) {return copy(other);};
00234 
00235   protected:
00236     /**
00237      * The data of the pyramid
00238      */
00239     std::vector<T> thePyramid;
00240 
00241     int resolutions;
00242   };
00243 
00244 } // namespace lti
00245 
00246 #include "ltiPyramid_inline.h"
00247 #include "ltiPyramid_template.h"
00248 
00249 #endif

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