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

vigra/imagecontainer.hxx VIGRA

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