36#ifndef VIGRA_IMAGECONTAINER_HXX
37#define VIGRA_IMAGECONTAINER_HXX
40#include "array_vector.hxx"
41#include "copyimage.hxx"
70template <
class ImageType,
71 class Alloc =
typename ImageType::allocator_type::template rebind<ImageType>::other >
85 typedef typename ImageVector::iterator iterator;
86 typedef typename ImageVector::const_iterator const_iterator;
87 typedef typename ImageVector::reverse_iterator reverse_iterator;
88 typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
89 typedef typename ImageVector::reference reference;
90 typedef typename ImageVector::const_reference const_reference;
91#if !defined(_MSC_VER) || _MSC_VER >= 1300
92 typedef typename ImageVector::pointer pointer;
94 typedef typename ImageVector::difference_type difference_type;
95 typedef typename ImageVector::size_type size_type;
100 Alloc
const & alloc = Alloc())
102 images_(numImages, ImageType(), alloc)
104 for(
unsigned int i=0; i<numImages; i++)
112 ImageArray(
unsigned int numImages= 0, Alloc
const & alloc = Alloc())
113 : images_(numImages, alloc)
121 ImageArray(
unsigned int numImages,
const ImageType &image, Alloc
const & alloc = Alloc())
122 : imageSize_(image.
size()),
123 images_(numImages, image, alloc)
132 template<
class InputIterator>
146 return images_[index];
154 return images_[index];
162 return images_.
begin();
170 return images_.
begin();
178 return images_.
end();
184 const_iterator
end()
const
186 return images_.
end();
213 return images_.
rend();
220 const_reverse_iterator
rend()
const
222 return images_.
rend();
230 return images_.
size();
239 return images_.max_size();
247 return images_.
empty();
258 && (images_ == other.images_);
263 iterator
insert(iterator pos, const_reference image)
265 return images_.insert(pos, image);
271 void insert (iterator pos, size_type count, const_reference image);
276 template<
class InputIterator>
287 return images_.erase(pos);
312 if (newSize !=
size())
314 size_type oldSize=
size();
315 images_.resize(newSize);
316 for (size_type i= oldSize; i<newSize; i++)
327 void resize(size_type newSize, ImageType &image)
329 if (newSize !=
size())
331 vigra_precondition(image.size() ==
imageSize(),
332 "trying to append images of wrong size to ImageArray with resize()");
333 images_.resize(newSize, image);
341 return images_.
front();
348 return images_.
front();
355 return images_.
back();
362 return images_.
back();
369 images_.push_back(image);
382 void swap(const_reference other)
384 Size2D oldImageSize = imageSize_;
385 images_.swap(other.images_);
386 imageSize_ = other.imageSize_;
387 other.imageSize_ = oldImageSize;
395 return images_.capacity();
412 {
return imageSize_; }
422 for(
unsigned int i=0; i<
size(); i++)
466template <
class ImageType,
467 class Alloc =
typename ImageType::allocator_type::template rebind<ImageType>::other >
470 int lowestLevel_, highestLevel_;
481 typedef typename ImageVector::iterator iterator;
482 typedef typename ImageVector::const_iterator const_iterator;
483 typedef typename ImageVector::reverse_iterator reverse_iterator;
484 typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
485 typedef typename ImageVector::reference reference;
486 typedef typename ImageVector::const_reference const_reference;
487#if !defined(_MSC_VER) || _MSC_VER >= 1300
488 typedef typename ImageVector::pointer pointer;
490 typedef typename ImageVector::difference_type difference_type;
491 typedef int size_type;
504 const Diff2D &imageSize,
int sizeAppliesToLevel = 0,
505 Alloc
const & alloc = Alloc())
506 : lowestLevel_(0), highestLevel_(-1),
525 const ImageType &image,
int copyImageToLevel = 0,
526 Alloc
const & alloc = Alloc())
527 : lowestLevel_(0), highestLevel_(-1),
531 copyImage(srcImageRange(image), destImage((*
this)[copyImageToLevel]));
546 template <
class SrcIterator,
class SrcAccessor>
548 SrcIterator ul, SrcIterator lr, SrcAccessor src,
549 int copyImageToLevel = 0,
550 Alloc
const & alloc = Alloc())
551 : lowestLevel_(0), highestLevel_(-1),
555 copyImage(srcIterRange(ul, lr, src), destImage((*
this)[copyImageToLevel]));
561 : lowestLevel_(0), highestLevel_(-1),
578 return highestLevel_;
586 return images_[index - lowestLevel_];
594 return images_[index - lowestLevel_];
602 return images_.
begin();
610 return images_.
begin();
618 return images_.
end();
624 const_iterator
end()
const
626 return images_.
end();
653 return images_.
rend();
660 const_reverse_iterator
rend()
const
662 return images_.
rend();
670 return images_.
size();
678 return images_.
empty();
688 return (lowestLevel_ == other.lowestLevel_) && (highestLevel_ == other.highestLevel_) &&
689 (images_ == other.images_);
707 const Diff2D &imageSize,
int sizeAppliesToLevel = 0)
710 "ImagePyramid::resize(): lowestLevel <= highestLevel required.");
712 "ImagePyramid::resize(): sizeAppliesToLevel must be between lowest and highest level (inclusive).");
716 images[sizeAppliesToLevel -
lowestLevel].resize(imageSize);
719 unsigned int w = (images[i - 1 -
lowestLevel].width() + 1) / 2;
720 unsigned int h = (images[i - 1 -
lowestLevel].height() + 1) / 2;
723 for(
int i=sizeAppliesToLevel - 1; i>=
lowestLevel; --i)
725 unsigned int w = 2*images[i + 1 -
lowestLevel].width() - 1;
726 unsigned int h = 2*images[i + 1 -
lowestLevel].height() - 1;
730 images_.swap(images);
739 return images_.
front();
746 return images_.
front();
753 return images_.
back();
760 return images_.
back();
768 images_.swap(other.images_);
769 std::swap(lowestLevel_, other.lowestLevel_);
770 std::swap(highestLevel_, other.highestLevel_);
const_iterator begin() const
Definition: array_vector.hxx:223
size_type size() const
Definition: array_vector.hxx:358
bool empty() const
Definition: array_vector.hxx:351
reverse_iterator rend()
Definition: array_vector.hxx:279
reference front()
Definition: array_vector.hxx:307
const_iterator end() const
Definition: array_vector.hxx:237
reverse_iterator rbegin()
Definition: array_vector.hxx:265
reference back()
Definition: array_vector.hxx:321
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:73
void pop_back()
Definition: imagecontainer.hxx:374
const_reverse_iterator rend() const
Definition: imagecontainer.hxx:220
const_reference front() const
Definition: imagecontainer.hxx:346
void insert(iterator pos, size_type count, const_reference image)
void resize(size_type newSize, ImageType &image)
Definition: imagecontainer.hxx:327
const_iterator begin() const
Definition: imagecontainer.hxx:168
void push_back(const_reference image)
Definition: imagecontainer.hxx:367
bool empty()
Definition: imagecontainer.hxx:245
ImageArray(unsigned int numImages, const ImageType &image, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:121
void reserve(size_type n)
Definition: imagecontainer.hxx:400
iterator insert(iterator pos, const_reference image)
Definition: imagecontainer.hxx:263
virtual void resizeImages(const Diff2D &newSize)
Definition: imagecontainer.hxx:418
size_type size() const
Definition: imagecontainer.hxx:228
const_reference back() const
Definition: imagecontainer.hxx:360
reverse_iterator rend()
Definition: imagecontainer.hxx:211
reference front()
Definition: imagecontainer.hxx:339
void swap(const_reference other)
Definition: imagecontainer.hxx:382
void resize(size_type newSize)
Definition: imagecontainer.hxx:310
void resizeImages(int width, int height)
Definition: imagecontainer.hxx:435
void insert(iterator pos, InputIterator begin, InputIterator end)
Definition: imagecontainer.hxx:277
size_type max_size() const
Definition: imagecontainer.hxx:237
reference operator[](size_type index)
Definition: imagecontainer.hxx:144
ImageType value_type
Definition: imagecontainer.hxx:83
Size2D imageSize() const
Definition: imagecontainer.hxx:411
ImageArray(InputIterator begin, InputIterator end, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:133
void clear()
Definition: imagecontainer.hxx:300
ImageArray(unsigned int numImages, const Diff2D &imageSize, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:99
iterator end()
Definition: imagecontainer.hxx:176
ImageArray(unsigned int numImages=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:112
const_iterator end() const
Definition: imagecontainer.hxx:184
reverse_iterator rbegin()
Definition: imagecontainer.hxx:193
size_type capacity() const
Definition: imagecontainer.hxx:393
iterator erase(iterator begin, iterator end)
Definition: imagecontainer.hxx:293
iterator begin()
Definition: imagecontainer.hxx:160
bool operator==(const ImageArray< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:255
const_reverse_iterator rbegin() const
Definition: imagecontainer.hxx:202
reference back()
Definition: imagecontainer.hxx:353
iterator erase(iterator pos)
Definition: imagecontainer.hxx:285
Class template for logarithmically tapering image pyramids.
Definition: imagecontainer.hxx:469
const_reverse_iterator rend() const
Definition: imagecontainer.hxx:660
const_reference front() const
Definition: imagecontainer.hxx:744
const_iterator begin() const
Definition: imagecontainer.hxx:608
void resize(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0)
Definition: imagecontainer.hxx:706
bool empty()
Definition: imagecontainer.hxx:676
ImagePyramid(int lowestLevel, int highestLevel, SrcIterator ul, SrcIterator lr, SrcAccessor src, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:547
ImagePyramid(Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:560
int highestLevel() const
Definition: imagecontainer.hxx:576
size_type size() const
Definition: imagecontainer.hxx:668
const_reference back() const
Definition: imagecontainer.hxx:758
reverse_iterator rend()
Definition: imagecontainer.hxx:651
reference front()
Definition: imagecontainer.hxx:737
void swap(ImagePyramid< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:766
reference operator[](size_type index)
Definition: imagecontainer.hxx:584
ImagePyramid(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:503
ImageType value_type
Definition: imagecontainer.hxx:479
void clear()
Definition: imagecontainer.hxx:694
bool operator==(const ImagePyramid< ImageType, Alloc > &other) const
Definition: imagecontainer.hxx:686
ImagePyramid(int lowestLevel, int highestLevel, const ImageType &image, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:524
iterator end()
Definition: imagecontainer.hxx:616
const_iterator end() const
Definition: imagecontainer.hxx:624
reverse_iterator rbegin()
Definition: imagecontainer.hxx:633
iterator begin()
Definition: imagecontainer.hxx:600
int lowestLevel() const
Definition: imagecontainer.hxx:569
const_reverse_iterator rbegin() const
Definition: imagecontainer.hxx:642
reference back()
Definition: imagecontainer.hxx:751
Two dimensional size object.
Definition: diff2d.hxx:483
void copyImage(...)
Copy source image into destination image.