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