36 #ifndef VIGRA_IMAGECONTAINER_HXX
37 #define VIGRA_IMAGECONTAINER_HXX
40 #include "array_vector.hxx"
41 #include "copyimage.hxx"
70 template <
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())
101 : imageSize_(imageSize),
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>
134 : imageSize_(begin!=end? (*begin).
size() :
Size2D(0,0)),
135 images_(begin, end, alloc)
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>
277 void insert(iterator pos, InputIterator begin, InputIterator end)
279 images_.insert(pos, begin, end);
287 return images_.erase(pos);
293 iterator
erase(iterator begin, iterator end)
295 return images_.erase(begin, end);
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++)
466 template <
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),
509 resize(lowestLevel, highestLevel, imageSize, sizeAppliesToLevel);
525 const ImageType &image,
int copyImageToLevel = 0,
526 Alloc
const & alloc = Alloc())
527 : lowestLevel_(0), highestLevel_(-1),
530 resize(lowestLevel, highestLevel, image.size(), copyImageToLevel);
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),
554 resize(lowestLevel, highestLevel, lr - ul, copyImageToLevel);
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_);
706 void resize(
int lowestLevel,
int highestLevel,
707 const Diff2D &imageSize,
int sizeAppliesToLevel = 0)
709 vigra_precondition(lowestLevel <= highestLevel,
710 "ImagePyramid::resize(): lowestLevel <= highestLevel required.");
711 vigra_precondition(lowestLevel <= sizeAppliesToLevel && sizeAppliesToLevel <= highestLevel,
712 "ImagePyramid::resize(): sizeAppliesToLevel must be between lowest and highest level (inclusive).");
714 ImageVector images(highestLevel - lowestLevel + 1, ImageType());
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_);
778 #endif // VIGRA_IMAGECONTAINER_HXX
Size2D imageSize() const
Definition: imagecontainer.hxx:411
const_reference front() const
Definition: imagecontainer.hxx:346
reference back()
Definition: array_vector.hxx:321
Fundamental class template for arrays of equal-sized images.
Definition: imagecontainer.hxx:72
reverse_iterator rbegin()
Definition: imagecontainer.hxx:633
const_reference back() const
Definition: imagecontainer.hxx:758
ImagePyramid(int lowestLevel, int highestLevel, SrcIterator ul, SrcIterator lr, SrcAccessor src, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:547
void insert(iterator pos, InputIterator begin, InputIterator end)
Definition: imagecontainer.hxx:277
void resize(size_type newSize, ImageType &image)
Definition: imagecontainer.hxx:327
void clear()
Definition: imagecontainer.hxx:300
ImageType value_type
Definition: imagecontainer.hxx:479
const_reverse_iterator rend() const
Definition: imagecontainer.hxx:660
bool empty() const
Definition: array_vector.hxx:351
size_type size() const
Definition: imagecontainer.hxx:668
const_iterator end() const
Definition: imagecontainer.hxx:184
const_iterator begin() const
Definition: array_vector.hxx:223
iterator erase(iterator begin, iterator end)
Definition: imagecontainer.hxx:293
const_iterator end() const
Definition: imagecontainer.hxx:624
ImagePyramid(Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:560
void push_back(const_reference image)
Definition: imagecontainer.hxx:367
reverse_iterator rend()
Definition: array_vector.hxx:279
reference front()
Definition: imagecontainer.hxx:737
Two dimensional difference vector.
Definition: diff2d.hxx:185
ImageType value_type
Definition: imagecontainer.hxx:83
const_reference back() const
Definition: imagecontainer.hxx:360
bool operator==(const ImagePyramid< ImageType, Alloc > &other) const
Definition: imagecontainer.hxx:686
iterator begin()
Definition: imagecontainer.hxx:160
reference operator[](size_type index)
Definition: imagecontainer.hxx:144
bool empty()
Definition: imagecontainer.hxx:676
iterator begin()
Definition: imagecontainer.hxx:600
Two dimensional size object.
Definition: diff2d.hxx:482
bool empty()
Definition: imagecontainer.hxx:245
ImageArray(unsigned int numImages, const Diff2D &imageSize, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:99
reverse_iterator rend()
Definition: imagecontainer.hxx:651
void resize(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0)
Definition: imagecontainer.hxx:706
reference back()
Definition: imagecontainer.hxx:353
ImageArray(unsigned int numImages=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:112
bool operator==(const ImageArray< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:255
reference front()
Definition: imagecontainer.hxx:339
reference front()
Definition: array_vector.hxx:307
ImageArray(InputIterator begin, InputIterator end, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:133
void clear()
Definition: imagecontainer.hxx:694
void resizeImages(int width, int height)
Definition: imagecontainer.hxx:435
size_type size() const
Definition: imagecontainer.hxx:228
void swap(const_reference other)
Definition: imagecontainer.hxx:382
const_reverse_iterator rbegin() const
Definition: imagecontainer.hxx:202
void copyImage(...)
Copy source image into destination image.
reverse_iterator rend()
Definition: imagecontainer.hxx:211
iterator end()
Definition: imagecontainer.hxx:616
void reserve(size_type n)
Definition: imagecontainer.hxx:400
ImagePyramid(int lowestLevel, int highestLevel, const ImageType &image, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:524
ImageArray(unsigned int numImages, const ImageType &image, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:121
size_type max_size() const
Definition: imagecontainer.hxx:237
const_reverse_iterator rend() const
Definition: imagecontainer.hxx:220
ImagePyramid(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:503
int highestLevel() const
Definition: imagecontainer.hxx:576
void resize(size_type newSize)
Definition: imagecontainer.hxx:310
void pop_back()
Definition: imagecontainer.hxx:374
reverse_iterator rbegin()
Definition: array_vector.hxx:265
int lowestLevel() const
Definition: imagecontainer.hxx:569
const_iterator end() const
Definition: array_vector.hxx:237
size_type size() const
Definition: array_vector.hxx:358
reference operator[](size_type index)
Definition: imagecontainer.hxx:584
iterator erase(iterator pos)
Definition: imagecontainer.hxx:285
iterator end()
Definition: imagecontainer.hxx:176
reverse_iterator rbegin()
Definition: imagecontainer.hxx:193
reference back()
Definition: imagecontainer.hxx:751
Class template for logarithmically tapering image pyramids.
Definition: imagecontainer.hxx:468
virtual void resizeImages(const Diff2D &newSize)
Definition: imagecontainer.hxx:418
const_iterator begin() const
Definition: imagecontainer.hxx:608
size_type capacity() const
Definition: imagecontainer.hxx:393
void swap(ImagePyramid< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:766
const_reference front() const
Definition: imagecontainer.hxx:744
const_reverse_iterator rbegin() const
Definition: imagecontainer.hxx:642
iterator insert(iterator pos, const_reference image)
Definition: imagecontainer.hxx:263
const_iterator begin() const
Definition: imagecontainer.hxx:168