VIGRA - VIGRA: vigra/imagecontainer.hxx Source File

[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

# vigra/imagecontainer.hxx

    00001 /************************************************************************/
    00002 /*                                                                      */
    00003 /*               Copyright 1998-2002 by Ullrich Koethe                  */
    00004 /*       Cognitive Systems Group, University of Hamburg, Germany        */
    00005 /*                                                                      */
    00006 /*    This file is part of the VIGRA computer vision library.           */
    00007 /*    ( Version 1.6.0, Aug 13 2008 )                                    */
    00008 /*    The VIGRA Website is                                              */
    00009 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
    00010 /*    Please direct questions, bug reports, and contributions to        */
    00011 /*        ullrich.koethe@iwr.uni-heidelberg.de    or                    */
    00012 /*        vigra@informatik.uni-hamburg.de                               */
    00013 /*                                                                      */
    00014 /*    Permission is hereby granted, free of charge, to any person       */
    00015 /*    obtaining a copy of this software and associated documentation    */
    00016 /*    files (the "Software"), to deal in the Software without           */
    00017 /*    restriction, including without limitation the rights to use,      */
    00018 /*    copy, modify, merge, publish, distribute, sublicense, and/or      */
    00019 /*    sell copies of the Software, and to permit persons to whom the    */
    00020 /*    Software is furnished to do so, subject to the following          */
    00021 /*    conditions:                                                       */
    00022 /*                                                                      */
    00023 /*    The above copyright notice and this permission notice shall be    */
    00024 /*    included in all copies or substantial portions of the             */
    00025 /*    Software.                                                         */
    00026 /*                                                                      */
    00027 /*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
    00028 /*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
    00029 /*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
    00030 /*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
    00031 /*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
    00032 /*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
    00033 /*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
    00034 /*    OTHER DEALINGS IN THE SOFTWARE.                                   */
    00035 /*                                                                      */
    00036 /************************************************************************/
    00037
    00038 #ifndef VIGRA_IMAGECONTAINER_HXX
    00039 #define VIGRA_IMAGECONTAINER_HXX
    00040
    00041 #include "utilities.hxx"
    00042 #include "array_vector.hxx"
    00043 #include "copyimage.hxx"
    00044
    00045 namespace vigra {
    00046
    00047 /** \addtogroup ImageContainers Image Containers
    00048     Classes to manage multiple images (ImageArray..)
    00049 */
    00050 //@{
    00051
    00052 /********************************************************/
    00053 /*                                                      */
    00054 /*                      ImageArray                      */
    00055 /*                                                      */
    00056 /********************************************************/
    00057
    00058 /** \brief Fundamental class template for arrays of equal-sized images.
    00059
    00060     An ImageArray manages an array of images of the type given as
    00061     template parameter. Use it like a ArrayVector<ImageType>, it has
    00062     the same interface, only operator< is missing from ImageArray. It
    00063     offers additional functions for resizing the images and querying
    00064     their common size. See \ref imageSize() for additional notes.
    00065
    00066     A custimized allocator can be passed as a template argument and via the constructor.
    00067     By default, the allocator of the <tt>ImageType</tt> is reused.
    00068
    00069     <b>\#include</b> <<a href="imagecontainer_8hxx-source.html">vigra/imagecontainer.hxx</a>>
    00070
    00071     Namespace: vigra
    00072 */
    00073 template <class ImageType,
    00074       class Alloc = typename ImageType::allocator_type::template rebind<ImageType>::other >
    00075 class ImageArray
    00076 {
    00077     Size2D imageSize_;
    00078
    00079 protected:
    00080     typedef ArrayVector<ImageType, Alloc> ImageVector;
    00081     ImageVector images_;
    00082
    00083 public:
    00084         /** the type of the contained values/images
    00085          */
    00086     typedef ImageType    value_type;
    00087
    00088     typedef typename ImageVector::iterator iterator;
    00089     typedef typename ImageVector::const_iterator const_iterator;
    00090     typedef typename ImageVector::reverse_iterator reverse_iterator;
    00091     typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
    00092     typedef typename ImageVector::reference reference;
    00093     typedef typename ImageVector::const_reference const_reference;
    00094 #if !defined(_MSC_VER) || _MSC_VER >= 1300
    00095     typedef typename ImageVector::pointer pointer;
    00096 #endif
    00097     typedef typename ImageVector::difference_type difference_type;
    00098     typedef typename ImageVector::size_type size_type;
    00099
    00100         /** init an array of numImages equal-sized images; use the specified allocator.
    00101          */
    00102     ImageArray(unsigned int numImages, const Diff2D &imageSize,
    00103                Alloc const & alloc = Alloc())
    00104         : imageSize_(imageSize),
    00105           images_(numImages, ImageType(), alloc)
    00106     {
    00107         for(unsigned int i=0; i<numImages; i++)
    00108             images_[i].resize(Size2D(imageSize));
    00109     }
    00110
    00111         /** Init an array of numImages equal-sized images. The size
    00112             depends on ImageType's default constructor (so it will
    00113             usually be 0x0); use the specified allocator.
    00114          */
    00115     ImageArray(unsigned int numImages= 0, Alloc const & alloc = Alloc())
    00116         : images_(numImages, alloc)
    00117     {
    00118         imageSize_= empty()? Size2D(0, 0) : front().size();
    00119     }
    00120
    00121         /** fill constructor: Init an array with numImages copies of
    00122             the given image. (STL-Sequence interface); use the specified allocator.
    00123          */
    00124     ImageArray(unsigned int numImages, const ImageType &image, Alloc const & alloc = Alloc())
    00125         : imageSize_(image.size()),
    00126           images_(numImages, image, alloc)
    00127     {
    00128     }
    00129
    00130         /** range constructor: Construct an array containing copies of
    00131             the images in [begin, end). Those images must all have the
    00132             same size, see \ref imageSize(). (STL-Sequence interface);
    00133             use the specified allocator.
    00134          */
    00135     template<class InputIterator>
    00136     ImageArray(InputIterator begin, InputIterator end, Alloc const & alloc = Alloc())
    00137         : imageSize_(begin!=end? (*begin).size() : Size2D(0,0)),
    00138           images_(begin, end, alloc)
    00139     {
    00140     }
    00141
    00142     virtual ~ImageArray() {}
    00143
    00144         /** Operator for a vector-like access to the contained images
    00145             (STL-Vector interface)
    00146          */
    00147     reference operator [](size_type index)
    00148     {
    00149         return images_[index];
    00150     }
    00151
    00152         /** Operator for a vector-like access to the contained images
    00153             (STL-Vector interface)
    00154          */
    00155     const_reference operator [](size_type index) const
    00156     {
    00157         return images_[index];
    00158     }
    00159
    00160         /** Returns an iterator pointing to the first image
    00161             (STL-Container interface)
    00162          */
    00163     iterator begin()
    00164     {
    00165         return images_.begin();
    00166     }
    00167
    00168         /** Returns an iterator pointing to the first image
    00169             (STL-Container interface)
    00170          */
    00171     const_iterator begin() const
    00172     {
    00173         return images_.begin();
    00174     }
    00175
    00176         /** Returns an iterator pointing behind the last image
    00177             (STL-Container interface)
    00178          */
    00179     iterator end()
    00180     {
    00181         return images_.end();
    00182     }
    00183
    00184         /** Returns an iterator pointing behind the last image
    00185             (STL-Container interface)
    00186          */
    00187     const_iterator end() const
    00188     {
    00189         return images_.end();
    00190     }
    00191
    00192         /** Returns a reverse_iterator pointing to the first image of
    00193             the reversed view of this array (STL-Reversable Container
    00194             interface)
    00195          */
    00196     reverse_iterator rbegin()
    00197     {
    00198         return images_.rbegin();
    00199     }
    00200
    00201         /** Returns a reverse_iterator pointing to the first image of
    00202             the reversed view of this array (STL-Reversable Container
    00203             interface)
    00204          */
    00205     const_reverse_iterator rbegin() const
    00206     {
    00207         return images_.rbegin();
    00208     }
    00209
    00210         /** Returns a reverse_iterator pointing behind the last image
    00211             of the reversed view of this array (STL-Reversable
    00212             Container interface)
    00213          */
    00214     reverse_iterator rend()
    00215     {
    00216         return images_.rend();
    00217     }
    00218
    00219         /** Returns a reverse_iterator pointing behind the last image
    00220             of the reversed view of this array (STL-Reversable
    00221             Container interface)
    00222          */
    00223     const_reverse_iterator rend() const
    00224     {
    00225         return images_.rend();
    00226     }
    00227
    00228         /** Query size of this ImageArray, that is: the number of
    00229             images. (STL-Container interface)
    00230         */
    00231     size_type size() const
    00232     {
    00233         return images_.size();
    00234     }
    00235
    00236         /** Query maximum size of this ImageArray, that is: the
    00237             max. parameter you may pass to resize(). (STL-Container
    00238             interface)
    00239         */
    00240     size_type max_size() const
    00241     {
    00242         return images_.max_size();
    00243     }
    00244
    00245         /** Returns true if and only if there are no contained
    00246             images. (STL-Container interface)
    00247         */
    00248     bool empty()
    00249     {
    00250         return images_.empty();
    00251     }
    00252
    00253         /** Returns true if and only if both ImageArrays have exactly
    00254             the same contents and all images did compare equal with the
    00255             corresponding image in the other ImageArray. (STL-Forward
    00256             Container interface)
    00257          */
    00258     bool operator ==(const ImageArray<ImageType> &other)
    00259     {
    00260         return (imageSize() == other.imageSize())
    00261                 && (images_ == other.images_);
    00262     }
    00263
    00264         /** Insert image at/before pos. (STL-Sequence interface)
    00265          */
    00266     iterator insert(iterator pos, const_reference image)
    00267     {
    00268         return images_.insert(pos, image);
    00269     }
    00270
    00271         /** Insert count copies of image at/before pos. (STL-Sequence
    00272             interface)
    00273          */
    00274     void insert (iterator pos, size_type count, const_reference image);
    00275
    00276         /** Insert copies of images from [begin, end) at/before
    00277             pos. (STL-Sequence interface)
    00278          */
    00279     template<class InputIterator>
    00280     void insert(iterator pos, InputIterator begin, InputIterator end)
    00281     {
    00282         images_.insert(pos, begin, end);
    00283     }
    00284
    00285         /** Removes the image at pos from this array. (STL-Sequence
    00286             interface)
    00287          */
    00288     iterator erase(iterator pos)
    00289     {
    00290         return images_.erase(pos);
    00291     }
    00292
    00293         /** Removes the images from [begin, end) from this
    00294             array. (STL-Sequence interface)
    00295          */
    00296     iterator erase(iterator begin, iterator end)
    00297     {
    00298         return images_.erase(begin, end);
    00299     }
    00300
    00301         /** Empty this array. (STL-Sequence interface)
    00302          */
    00303     void clear()
    00304     {
    00305         images_.clear();
    00306     }
    00307
    00308         /** Resize this ImageArray, throwing the last images away if
    00309             you make the array smaller or appending new images of the
    00310             right size at the end of the array if you make it
    00311             larger. (STL-Sequence interface)
    00312         */
    00313     void resize(size_type newSize)
    00314     {
    00315         if (newSize != size())
    00316         {
    00317             size_type oldSize= size();
    00318             images_.resize(newSize);
    00319             for (size_type i= oldSize; i<newSize; i++)
    00320                 images_[i].resize(imageSize());
    00321         }
    00322     }
    00323
    00324         /** Resize this ImageArray, throwing the last images away if
    00325             you make the array smaller or appending new copies of image
    00326             at the end of the array if you make it larger.
    00327             precondition: <tt>image.size() == imageSize()</tt>
    00328             (STL-Sequence interface)
    00329         */
    00330     void resize(size_type newSize, ImageType &image)
    00331     {
    00332         if (newSize != size())
    00333         {
    00334             vigra_precondition(image.size() == imageSize(),
    00335                                "trying to append images of wrong size to ImageArray with resize()");
    00336             images_.resize(newSize, image);
    00337         }
    00338     }
    00339
    00340         /** return the first image. (STL-Sequence interface)
    00341          */
    00342     reference front()
    00343     {
    00344         return images_.front();
    00345     }
    00346
    00347         /** return the first image. (STL-Sequence interface)
    00348          */
    00349     const_reference front() const
    00350     {
    00351         return images_.front();
    00352     }
    00353
    00354         /** return the last image. (STL-Vector interface)
    00355          */
    00356     reference back()
    00357     {
    00358         return images_.back();
    00359     }
    00360
    00361         /** return the last image. (STL-Vector interface)
    00362          */
    00363     const_reference back() const
    00364     {
    00365         return images_.back();
    00366     }
    00367
    00368         /** append image to array (STL-Back Insertion Sequence interface)
    00369          */
    00370     void push_back(const_reference image)
    00371     {
    00372         images_.push_back(image);
    00373     }
    00374
    00375         /** remove last image from array (STL-Back Insertion Sequence interface)
    00376          */
    00377     void pop_back()
    00378     {
    00379         images_.pop_back();
    00380     }
    00381
    00382         /** swap contents of this array with the contents of other
    00383             (STL-Container interface)
    00384          */
    00385     void swap(const_reference other)
    00386     {
    00387         Size2D oldImageSize = imageSize_;
    00388         images_.swap(other.images_);
    00389         imageSize_ = other.imageSize_;
    00390         other.imageSize_ = oldImageSize;
    00391     }
    00392
    00393         /** number of image objects for which memory has been allocated
    00394             (STL-Vector interface)
    00395         */
    00396     size_type capacity() const
    00397     {
    00398         return images_.capacity();
    00399     }
    00400
    00401         /** increase capacity(). (STL-Vector interface)
    00402          */
    00403     void reserve(size_type n)
    00404     {
    00405         images_.reserve(n);
    00406     }
    00407
    00408         /** Query the size of the contained images. ImageArray will
    00409             maintain an array of equal-sized images of this
    00410             size. However, <em>do not resize the contained images
    00411             manually</em>. ImageArray currently has no way to detect or
    00412             prevent this.
    00413          */
    00414     Size2D imageSize() const
    00415         { return imageSize_; }
    00416
    00417         /** Resize all images to a common new size (No-op if
    00418             <tt>newSize == imageSize()</tt>). See \ref imageSize() for
    00419             an important note about resizing the images.
    00420         */
    00421     virtual void resizeImages(const Diff2D &newSize)
    00422     {
    00423         if (newSize!=imageSize())
    00424         {
    00425             for(unsigned int i=0; i<size(); i++)
    00426                 images_[i].resize(Size2D(newSize));
    00427             imageSize_= newSize;
    00428         }
    00429     }
    00430
    00431         /** Resize all images to a common new size (No-op if
    00432             <tt>newSize == imageSize()</tt>). See \ref imageSize() for
    00433             an important note about resizing the images.
    00434
    00435             (Convenience function, same as calling
    00436             <tt>resizeImages(Diff2D(width, height));</tt>.)
    00437         */
    00438     void resizeImages(int width, int height)
    00439     {
    00440         resizeImages(Size2D(width, height));
    00441     }
    00442 };
    00443
    00444 /********************************************************/
    00445 /*                                                      */
    00446 /*                      ImagePyramid                    */
    00447 /*                                                      */
    00448 /********************************************************/
    00449
    00450 /** \brief Class template for logarithmically tapering image pyramids.
    00451
    00452     An ImagePyramid manages an array of images of the type given as
    00453     template parameter, where each level has half the width and height
    00454     of its predecessor.  It actually represents a sequence of pyramid
    00455     levels whose start and end index are configurable.  For Burt-style
    00456     pyramids, see also \ref pyramidReduceBurtFilter and \ref
    00457     pyramidExpandBurtFilter.
    00458
    00459     A custimized allocator can be passed as a template argument and
    00460     via the constructor.  By default, the allocator of the
    00461     <tt>ImageType</tt> is reused.
    00462
    00463     <b>\#include</b> <<a href="imagecontainer_8hxx-source.html">vigra/imagecontainer.hxx</a>>
    00464
    00465     Namespace: vigra
    00466 */
    00467 template <class ImageType,
    00468       class Alloc = typename ImageType::allocator_type::template rebind<ImageType>::other >
    00469 class ImagePyramid
    00470 {
    00471     int lowestLevel_, highestLevel_;
    00472
    00473 protected:
    00474     typedef ArrayVector<ImageType, Alloc> ImageVector;
    00475     ImageVector images_;
    00476
    00477 public:
    00478         /** the type of the contained values/images
    00479          */
    00480     typedef ImageType    value_type;
    00481
    00482     typedef typename ImageVector::iterator iterator;
    00483     typedef typename ImageVector::const_iterator const_iterator;
    00484     typedef typename ImageVector::reverse_iterator reverse_iterator;
    00485     typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
    00486     typedef typename ImageVector::reference reference;
    00487     typedef typename ImageVector::const_reference const_reference;
    00488 #if !defined(_MSC_VER) || _MSC_VER >= 1300
    00489     typedef typename ImageVector::pointer pointer;
    00490 #endif
    00491     typedef typename ImageVector::difference_type difference_type;
    00492     typedef int size_type;
    00493
    00494         /** Init a pyramid between the given levels (inclusive).
    00495          *
    00496          * Allocate the given \a imageSize at the pyramid level given
    00497          * in \a sizeAppliesToLevel (default: level 0 / bottom) and
    00498          * size the other levels using recursive reduction/expansion
    00499          * by factors of 2.  Use the specified allocator for image
    00500          * creation.  The image type must be default constructible and
    00501          * resizable.  sizeAppliesToLevel must be the in range
    00502          * lowestLevel..highestLevel (inclusive).
    00503          */
    00504     ImagePyramid(int lowestLevel, int highestLevel,
    00505                  const Diff2D &imageSize, int sizeAppliesToLevel = 0,
    00506                  Alloc const & alloc = Alloc())
    00507         : lowestLevel_(0), highestLevel_(-1),
    00508           images_(alloc)
    00509     {
    00510         resize(lowestLevel, highestLevel, imageSize, sizeAppliesToLevel);
    00511     }
    00512
    00513         /**
    00514          * Init a pyramid between the given levels (inclusive).
    00515          *
    00516          * Copy the given \a image into the pyramid level given in \a
    00517          * copyImageToLevel (default: level 0 / bottom) and size the
    00518          * other levels using recursive reduction/expansion by factors
    00519          * of 2 (their image data is not initialized).  Use the
    00520          * specified allocator for image creation.  The image type
    00521          * must be default constructible and resizable.
    00522          * sizeAppliesToLevel must be the in range
    00523          * lowestLevel..highestLevel (inclusive).
    00524          */
    00525     ImagePyramid(int lowestLevel, int highestLevel,
    00526                  const ImageType &image, int copyImageToLevel = 0,
    00527                  Alloc const & alloc = Alloc())
    00528         : lowestLevel_(0), highestLevel_(-1),
    00529           images_(alloc)
    00530     {
    00531         resize(lowestLevel, highestLevel, image.size(), copyImageToLevel);
    00532         copyImage(srcImageRange(image), destImage((*this)[copyImageToLevel]));
    00533     }
    00534
    00535         /**
    00536          * Init a pyramid between the given levels (inclusive).
    00537          *
    00538          * Copy the image given by the range \a ul to \a lr into the
    00539          * pyramid level given in \a copyImageToLevel (default: level
    00540          * 0 / bottom) and size the other levels using recursive
    00541          * reduction/expansion by factors of 2 (their image data is
    00542          * not initialized).  Use the specified allocator for image
    00543          * creation.  The image type must be default constructible and
    00544          * resizable.  sizeAppliesToLevel must be the in range
    00545          * lowestLevel..highestLevel (inclusive).
    00546          */
    00547     template <class SrcIterator, class SrcAccessor>
    00548     ImagePyramid(int lowestLevel, int highestLevel,
    00549                  SrcIterator ul, SrcIterator lr, SrcAccessor src,
    00550                  int copyImageToLevel = 0,
    00551                  Alloc const & alloc = Alloc())
    00552         : lowestLevel_(0), highestLevel_(-1),
    00553           images_(alloc)
    00554     {
    00555         resize(lowestLevel, highestLevel, lr - ul, copyImageToLevel);
    00556         copyImage(srcIterRange(ul, lr, src), destImage((*this)[copyImageToLevel]));
    00557     }
    00558
    00559         /** Init an empty pyramid.  Use the specified allocator.
    00560          */
    00561     ImagePyramid(Alloc const & alloc = Alloc())
    00562         : lowestLevel_(0), highestLevel_(-1),
    00563           images_(alloc)
    00564     {}
    00565
    00566     virtual ~ImagePyramid() {}
    00567
    00568         /** Get the index of the lowest allocated level of the pyramid.
    00569         */
    00570     int lowestLevel() const
    00571     {
    00572         return lowestLevel_;
    00573     }
    00574
    00575         /** Get the index of the highest allocated level of the pyramid.
    00576         */
    00577     int highestLevel() const
    00578     {
    00579         return highestLevel_;
    00580     }
    00581
    00582         /** Operator for a vector-like access to the contained images
    00583             (STL-Vector interface)
    00584          */
    00585     reference operator [](size_type index)
    00586     {
    00587         return images_[index - lowestLevel_];
    00588     }
    00589
    00590         /** Operator for a vector-like access to the contained images
    00591             (STL-Vector interface)
    00592          */
    00593     const_reference operator [](size_type index) const
    00594     {
    00595         return images_[index - lowestLevel_];
    00596     }
    00597
    00598         /** Returns an iterator pointing to the first image
    00599             (STL-Container interface)
    00600          */
    00601     iterator begin()
    00602     {
    00603         return images_.begin();
    00604     }
    00605
    00606         /** Returns an iterator pointing to the first image
    00607             (STL-Container interface)
    00608          */
    00609     const_iterator begin() const
    00610     {
    00611         return images_.begin();
    00612     }
    00613
    00614         /** Returns an iterator pointing behind the last image
    00615             (STL-Container interface)
    00616          */
    00617     iterator end()
    00618     {
    00619         return images_.end();
    00620     }
    00621
    00622         /** Returns an iterator pointing behind the last image
    00623             (STL-Container interface)
    00624          */
    00625     const_iterator end() const
    00626     {
    00627         return images_.end();
    00628     }
    00629
    00630         /** Returns a reverse_iterator pointing to the first image of
    00631             the reversed view of this array (STL-Reversable Container
    00632             interface)
    00633          */
    00634     reverse_iterator rbegin()
    00635     {
    00636         return images_.rbegin();
    00637     }
    00638
    00639         /** Returns a reverse_iterator pointing to the first image of
    00640             the reversed view of this array (STL-Reversable Container
    00641             interface)
    00642          */
    00643     const_reverse_iterator rbegin() const
    00644     {
    00645         return images_.rbegin();
    00646     }
    00647
    00648         /** Returns a reverse_iterator pointing behind the last image
    00649             of the reversed view of this array (STL-Reversable
    00650             Container interface)
    00651          */
    00652     reverse_iterator rend()
    00653     {
    00654         return images_.rend();
    00655     }
    00656
    00657         /** Returns a reverse_iterator pointing behind the last image
    00658             of the reversed view of this array (STL-Reversable
    00659             Container interface)
    00660          */
    00661     const_reverse_iterator rend() const
    00662     {
    00663         return images_.rend();
    00664     }
    00665
    00666         /** Query size of this ImageArray, that is: the number of
    00667             images. (STL-Container interface)
    00668         */
    00669     size_type size() const
    00670     {
    00671         return images_.size();
    00672     }
    00673
    00674         /** Returns true if and only if there are no contained
    00675             images. (STL-Container interface)
    00676         */
    00677     bool empty()
    00678     {
    00679         return images_.empty();
    00680     }
    00681
    00682         /** Returns true if and only if both ImageArrays have exactly
    00683             the same contents and all images did compare equal with the
    00684             corresponding image in the other ImageArray. (STL-Forward
    00685             Container interface)
    00686          */
    00687     bool operator ==(const ImagePyramid<ImageType, Alloc> &other) const
    00688     {
    00689         return (lowestLevel_ == other.lowestLevel_) && (highestLevel_ == other.highestLevel_) &&
    00690                 (images_ == other.images_);
    00691     }
    00692
    00693         /** Empty this array. (STL-Sequence interface)
    00694          */
    00695     void clear()
    00696     {
    00697         images_.clear();
    00698         lowestLevel_ = 0;
    00699         highestLevel_ = -1;
    00700     }
    00701
    00702         /** Resize this ImageArray, throwing the last images away if
    00703             you make the array smaller or appending new images of the
    00704             right size at the end of the array if you make it
    00705             larger. (STL-Sequence interface)
    00706         */
    00707     void resize(int lowestLevel, int highestLevel,
    00708                 const Diff2D &imageSize, int sizeAppliesToLevel = 0)
    00709     {
    00710         vigra_precondition(lowestLevel <= highestLevel,
    00711            "ImagePyramid::resize(): lowestLevel <= highestLevel required.");
    00712         vigra_precondition(lowestLevel <= sizeAppliesToLevel && sizeAppliesToLevel <= highestLevel,
    00713            "ImagePyramid::resize(): sizeAppliesToLevel must be between lowest and highest level (inclusive).");
    00714
    00715         ImageVector images(highestLevel - lowestLevel + 1, ImageType());
    00716
    00717         images[sizeAppliesToLevel - lowestLevel].resize(imageSize);
    00718         for(int i=sizeAppliesToLevel + 1; i<=highestLevel; ++i)
    00719         {
    00720             unsigned int w = (images[i - 1 - lowestLevel].width() + 1) / 2;
    00721             unsigned int h = (images[i - 1 - lowestLevel].height() + 1) / 2;
    00722             images[i - lowestLevel].resize(w, h);
    00723         }
    00724         for(int i=sizeAppliesToLevel - 1; i>=lowestLevel; --i)
    00725         {
    00726             unsigned int w = 2*images[i + 1 - lowestLevel].width() - 1;
    00727             unsigned int h = 2*images[i + 1 - lowestLevel].height() - 1;
    00728             images[i - lowestLevel].resize(w, h);
    00729         }
    00730
    00731         images_.swap(images);
    00732         lowestLevel_ = lowestLevel;
    00733         highestLevel_ = highestLevel;
    00734     }
    00735
    00736         /** return the first image (lowestLevel()). (STL-Sequence interface)
    00737          */
    00738     reference front()
    00739     {
    00740         return images_.front();
    00741     }
    00742
    00743         /** return the first image (lowestLevel()). (STL-Sequence interface)
    00744          */
    00745     const_reference front() const
    00746     {
    00747         return images_.front();
    00748     }
    00749
    00750         /** return the last image (highestLevel()). (STL-Vector interface)
    00751          */
    00752     reference back()
    00753     {
    00754         return images_.back();
    00755     }
    00756
    00757         /** return the last image (highestLevel()). (STL-Vector interface)
    00758          */
    00759     const_reference back() const
    00760     {
    00761         return images_.back();
    00762     }
    00763
    00764         /** swap contents of this array with the contents of other
    00765             (STL-Container interface)
    00766          */
    00767     void swap(const ImagePyramid<ImageType, Alloc> &other)
    00768     {
    00769         images_.swap(other.images_);
    00770         std::swap(lowestLevel_, other.lowestLevel_);
    00771         std::swap(highestLevel_, other.highestLevel_);
    00772     }
    00773 };
    00774
    00775 //@}
    00776
    00777 } // namespace vigra
    00778
    00779 #endif // VIGRA_IMAGECONTAINER_HXX

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python VIGRA 1.6.0 (13 Aug 2008)