36#ifndef VIGRA_IMAGECONTAINER_HXX
37#define VIGRA_IMAGECONTAINER_HXX
40#include "array_vector.hxx"
41#include "copyimage.hxx"
71template <
class ImageType,
72 class Alloc =
typename std::allocator_traits<typename ImageType::allocator_type>::template rebind_alloc<ImageType> >
86 typedef typename ImageVector::iterator iterator;
87 typedef typename ImageVector::const_iterator const_iterator;
88 typedef typename ImageVector::reverse_iterator reverse_iterator;
89 typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
90 typedef typename ImageVector::reference reference;
91 typedef typename ImageVector::const_reference const_reference;
92#if !defined(_MSC_VER) || _MSC_VER >= 1300
93 typedef typename ImageVector::pointer pointer;
95 typedef typename ImageVector::difference_type difference_type;
96 typedef typename ImageVector::size_type size_type;
101 Alloc
const & alloc = Alloc())
103 images_(numImages, ImageType(), alloc)
105 for(
unsigned int i=0; i<numImages; i++)
113 ImageArray(
unsigned int numImages= 0, Alloc
const & alloc = Alloc())
114 : images_(numImages, alloc)
122 ImageArray(
unsigned int numImages,
const ImageType &image, Alloc
const & alloc = Alloc())
123 : imageSize_(image.
size()),
124 images_(numImages, image, alloc)
133 template<
class InputIterator>
147 return images_[index];
155 return images_[index];
163 return images_.begin();
171 return images_.begin();
179 return images_.end();
185 const_iterator
end()
const
187 return images_.end();
196 return images_.rbegin();
205 return images_.rbegin();
214 return images_.rend();
221 const_reverse_iterator
rend()
const
223 return images_.rend();
231 return images_.size();
240 return images_.max_size();
248 return images_.empty();
259 && (images_ == other.images_);
264 iterator
insert(iterator pos, const_reference image)
266 return images_.insert(pos, image);
272 void insert (iterator pos, size_type count, const_reference image);
277 template<
class InputIterator>
288 return images_.erase(pos);
313 if (newSize !=
size())
315 size_type oldSize=
size();
316 images_.resize(newSize);
317 for (size_type i= oldSize; i<newSize; i++)
328 void resize(size_type newSize, ImageType &image)
330 if (newSize !=
size())
332 vigra_precondition(image.size() ==
imageSize(),
333 "trying to append images of wrong size to ImageArray with resize()");
334 images_.resize(newSize, image);
342 return images_.front();
349 return images_.front();
356 return images_.back();
363 return images_.back();
370 images_.push_back(image);
383 void swap(const_reference other)
385 Size2D oldImageSize = imageSize_;
386 images_.swap(other.images_);
387 imageSize_ = other.imageSize_;
388 other.imageSize_ = oldImageSize;
396 return images_.capacity();
413 {
return imageSize_; }
423 for(
unsigned int i=0; i<
size(); i++)
467template <
class ImageType,
468 class Alloc =
typename std::allocator_traits<typename ImageType::allocator_type>::template rebind_alloc<ImageType> >
471 int lowestLevel_, highestLevel_;
482 typedef typename ImageVector::iterator iterator;
483 typedef typename ImageVector::const_iterator const_iterator;
484 typedef typename ImageVector::reverse_iterator reverse_iterator;
485 typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
486 typedef typename ImageVector::reference reference;
487 typedef typename ImageVector::const_reference const_reference;
488#if !defined(_MSC_VER) || _MSC_VER >= 1300
489 typedef typename ImageVector::pointer pointer;
491 typedef typename ImageVector::difference_type difference_type;
492 typedef int size_type;
505 const Diff2D &imageSize,
int sizeAppliesToLevel = 0,
506 Alloc
const & alloc = Alloc())
507 : lowestLevel_(0), highestLevel_(-1),
526 const ImageType &image,
int copyImageToLevel = 0,
527 Alloc
const & alloc = Alloc())
528 : lowestLevel_(0), highestLevel_(-1),
532 copyImage(srcImageRange(image), destImage((*
this)[copyImageToLevel]));
547 template <
class SrcIterator,
class SrcAccessor>
549 SrcIterator ul, SrcIterator lr, SrcAccessor src,
550 int copyImageToLevel = 0,
551 Alloc
const & alloc = Alloc())
552 : lowestLevel_(0), highestLevel_(-1),
556 copyImage(srcIterRange(ul, lr, src), destImage((*
this)[copyImageToLevel]));
562 : lowestLevel_(0), highestLevel_(-1),
579 return highestLevel_;
587 return images_[index - lowestLevel_];
595 return images_[index - lowestLevel_];
603 return images_.begin();
611 return images_.begin();
619 return images_.end();
625 const_iterator
end()
const
627 return images_.end();
636 return images_.rbegin();
645 return images_.rbegin();
654 return images_.rend();
661 const_reverse_iterator
rend()
const
663 return images_.rend();
671 return images_.size();
679 return images_.empty();
689 return (lowestLevel_ == other.lowestLevel_) && (highestLevel_ == other.highestLevel_) &&
690 (images_ == other.images_);
708 const Diff2D &imageSize,
int sizeAppliesToLevel = 0)
711 "ImagePyramid::resize(): lowestLevel <= highestLevel required.");
713 "ImagePyramid::resize(): sizeAppliesToLevel must be between lowest and highest level (inclusive).");
717 images[sizeAppliesToLevel -
lowestLevel].resize(imageSize);
720 unsigned int w = (images[i - 1 -
lowestLevel].width() + 1) / 2;
721 unsigned int h = (images[i - 1 -
lowestLevel].height() + 1) / 2;
724 for(
int i=sizeAppliesToLevel - 1; i>=
lowestLevel; --i)
726 unsigned int w = 2*images[i + 1 -
lowestLevel].width() - 1;
727 unsigned int h = 2*images[i + 1 -
lowestLevel].height() - 1;
731 images_.swap(images);
740 return images_.front();
747 return images_.front();
754 return images_.back();
761 return images_.back();
769 images_.swap(other.images_);
770 std::swap(lowestLevel_, other.lowestLevel_);
771 std::swap(highestLevel_, other.highestLevel_);
Definition array_vector.hxx:514
Two dimensional difference vector.
Definition diff2d.hxx:186
Fundamental class template for arrays of equal-sized images.
Definition imagecontainer.hxx:74
void pop_back()
Definition imagecontainer.hxx:375
const_reverse_iterator rend() const
Definition imagecontainer.hxx:221
const_reference front() const
Definition imagecontainer.hxx:347
void insert(iterator pos, size_type count, const_reference image)
void resize(size_type newSize, ImageType &image)
Definition imagecontainer.hxx:328
const_iterator begin() const
Definition imagecontainer.hxx:169
void push_back(const_reference image)
Definition imagecontainer.hxx:368
bool empty()
Definition imagecontainer.hxx:246
ImageArray(unsigned int numImages, const ImageType &image, Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:122
void reserve(size_type n)
Definition imagecontainer.hxx:401
iterator insert(iterator pos, const_reference image)
Definition imagecontainer.hxx:264
virtual void resizeImages(const Diff2D &newSize)
Definition imagecontainer.hxx:419
size_type size() const
Definition imagecontainer.hxx:229
const_reference back() const
Definition imagecontainer.hxx:361
reverse_iterator rend()
Definition imagecontainer.hxx:212
reference front()
Definition imagecontainer.hxx:340
void swap(const_reference other)
Definition imagecontainer.hxx:383
void resize(size_type newSize)
Definition imagecontainer.hxx:311
void resizeImages(int width, int height)
Definition imagecontainer.hxx:436
void insert(iterator pos, InputIterator begin, InputIterator end)
Definition imagecontainer.hxx:278
size_type max_size() const
Definition imagecontainer.hxx:238
reference operator[](size_type index)
Definition imagecontainer.hxx:145
ImageType value_type
Definition imagecontainer.hxx:84
Size2D imageSize() const
Definition imagecontainer.hxx:412
ImageArray(InputIterator begin, InputIterator end, Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:134
void clear()
Definition imagecontainer.hxx:301
ImageArray(unsigned int numImages, const Diff2D &imageSize, Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:100
iterator end()
Definition imagecontainer.hxx:177
ImageArray(unsigned int numImages=0, Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:113
const_iterator end() const
Definition imagecontainer.hxx:185
reverse_iterator rbegin()
Definition imagecontainer.hxx:194
size_type capacity() const
Definition imagecontainer.hxx:394
iterator erase(iterator begin, iterator end)
Definition imagecontainer.hxx:294
iterator begin()
Definition imagecontainer.hxx:161
bool operator==(const ImageArray< ImageType, Alloc > &other)
Definition imagecontainer.hxx:256
const_reverse_iterator rbegin() const
Definition imagecontainer.hxx:203
reference back()
Definition imagecontainer.hxx:354
iterator erase(iterator pos)
Definition imagecontainer.hxx:286
Class template for logarithmically tapering image pyramids.
Definition imagecontainer.hxx:470
const_reverse_iterator rend() const
Definition imagecontainer.hxx:661
const_reference front() const
Definition imagecontainer.hxx:745
const_iterator begin() const
Definition imagecontainer.hxx:609
void resize(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0)
Definition imagecontainer.hxx:707
bool empty()
Definition imagecontainer.hxx:677
ImagePyramid(int lowestLevel, int highestLevel, SrcIterator ul, SrcIterator lr, SrcAccessor src, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:548
ImagePyramid(Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:561
int highestLevel() const
Definition imagecontainer.hxx:577
size_type size() const
Definition imagecontainer.hxx:669
const_reference back() const
Definition imagecontainer.hxx:759
reverse_iterator rend()
Definition imagecontainer.hxx:652
reference front()
Definition imagecontainer.hxx:738
void swap(ImagePyramid< ImageType, Alloc > &other)
Definition imagecontainer.hxx:767
reference operator[](size_type index)
Definition imagecontainer.hxx:585
ImagePyramid(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0, Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:504
ImageType value_type
Definition imagecontainer.hxx:480
void clear()
Definition imagecontainer.hxx:695
bool operator==(const ImagePyramid< ImageType, Alloc > &other) const
Definition imagecontainer.hxx:687
ImagePyramid(int lowestLevel, int highestLevel, const ImageType &image, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition imagecontainer.hxx:525
iterator end()
Definition imagecontainer.hxx:617
const_iterator end() const
Definition imagecontainer.hxx:625
reverse_iterator rbegin()
Definition imagecontainer.hxx:634
iterator begin()
Definition imagecontainer.hxx:601
int lowestLevel() const
Definition imagecontainer.hxx:570
const_reverse_iterator rbegin() const
Definition imagecontainer.hxx:643
reference back()
Definition imagecontainer.hxx:752
Two dimensional size object.
Definition diff2d.hxx:483
void copyImage(...)
Copy source image into destination image.