36 #ifndef VIGRA_IMAGECONTAINER_HXX
37 #define VIGRA_IMAGECONTAINER_HXX
39 #include "utilities.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())
123 images_(numImages, image, alloc)
132 template<
class InputIterator>
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++)
463 template <
class ImageType,
464 class Alloc =
typename ImageType::allocator_type::template rebind<ImageType>::other >
467 int lowestLevel_, highestLevel_;
478 typedef typename ImageVector::iterator iterator;
479 typedef typename ImageVector::const_iterator const_iterator;
480 typedef typename ImageVector::reverse_iterator reverse_iterator;
481 typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
482 typedef typename ImageVector::reference reference;
483 typedef typename ImageVector::const_reference const_reference;
484 #if !defined(_MSC_VER) || _MSC_VER >= 1300
485 typedef typename ImageVector::pointer pointer;
487 typedef typename ImageVector::difference_type difference_type;
488 typedef int size_type;
501 const Diff2D &imageSize,
int sizeAppliesToLevel = 0,
502 Alloc
const & alloc = Alloc())
503 : lowestLevel_(0), highestLevel_(-1),
506 resize(lowestLevel, highestLevel, imageSize, sizeAppliesToLevel);
522 const ImageType &image,
int copyImageToLevel = 0,
523 Alloc
const & alloc = Alloc())
524 : lowestLevel_(0), highestLevel_(-1),
527 resize(lowestLevel, highestLevel, image.size(), copyImageToLevel);
528 copyImage(srcImageRange(image), destImage((*
this)[copyImageToLevel]));
543 template <
class SrcIterator,
class SrcAccessor>
545 SrcIterator ul, SrcIterator lr, SrcAccessor src,
546 int copyImageToLevel = 0,
547 Alloc
const & alloc = Alloc())
548 : lowestLevel_(0), highestLevel_(-1),
551 resize(lowestLevel, highestLevel, lr - ul, copyImageToLevel);
552 copyImage(srcIterRange(ul, lr, src), destImage((*
this)[copyImageToLevel]));
558 : lowestLevel_(0), highestLevel_(-1),
575 return highestLevel_;
583 return images_[index - lowestLevel_];
591 return images_[index - lowestLevel_];
599 return images_.
begin();
607 return images_.
begin();
615 return images_.
end();
621 const_iterator
end()
const
623 return images_.
end();
650 return images_.
rend();
657 const_reverse_iterator
rend()
const
659 return images_.
rend();
667 return images_.
size();
675 return images_.
empty();
685 return (lowestLevel_ == other.lowestLevel_) && (highestLevel_ == other.highestLevel_) &&
686 (images_ == other.images_);
703 void resize(
int lowestLevel,
int highestLevel,
704 const Diff2D &imageSize,
int sizeAppliesToLevel = 0)
706 vigra_precondition(lowestLevel <= highestLevel,
707 "ImagePyramid::resize(): lowestLevel <= highestLevel required.");
708 vigra_precondition(lowestLevel <= sizeAppliesToLevel && sizeAppliesToLevel <= highestLevel,
709 "ImagePyramid::resize(): sizeAppliesToLevel must be between lowest and highest level (inclusive).");
711 ImageVector images(highestLevel - lowestLevel + 1, ImageType());
713 images[sizeAppliesToLevel -
lowestLevel].resize(imageSize);
716 unsigned int w = (images[i - 1 -
lowestLevel].width() + 1) / 2;
717 unsigned int h = (images[i - 1 -
lowestLevel].height() + 1) / 2;
720 for(
int i=sizeAppliesToLevel - 1; i>=
lowestLevel; --i)
722 unsigned int w = 2*images[i + 1 -
lowestLevel].width() - 1;
723 unsigned int h = 2*images[i + 1 -
lowestLevel].height() - 1;
727 images_.swap(images);
736 return images_.
front();
743 return images_.
front();
750 return images_.
back();
757 return images_.
back();
765 images_.swap(other.images_);
766 std::swap(lowestLevel_, other.lowestLevel_);
767 std::swap(highestLevel_, other.highestLevel_);
775 #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:293
Fundamental class template for arrays of equal-sized images.
Definition: imagecontainer.hxx:72
reverse_iterator rbegin()
Definition: imagecontainer.hxx:630
const_reference back() const
Definition: imagecontainer.hxx:755
ImagePyramid(int lowestLevel, int highestLevel, SrcIterator ul, SrcIterator lr, SrcAccessor src, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:544
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:476
const_reverse_iterator rend() const
Definition: imagecontainer.hxx:657
bool empty() const
Definition: array_vector.hxx:323
size_type size() const
Definition: imagecontainer.hxx:665
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:621
void push_back(const_reference image)
Definition: imagecontainer.hxx:367
reverse_iterator rend()
Definition: array_vector.hxx:265
reference front()
Definition: imagecontainer.hxx:734
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:683
iterator begin()
Definition: imagecontainer.hxx:160
reference operator[](size_type index)
Definition: imagecontainer.hxx:144
bool empty()
Definition: imagecontainer.hxx:673
iterator begin()
Definition: imagecontainer.hxx:597
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:648
void resize(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0)
Definition: imagecontainer.hxx:703
reference back()
Definition: imagecontainer.hxx:353
bool operator==(const ImageArray< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:255
reference front()
Definition: imagecontainer.hxx:339
reference front()
Definition: array_vector.hxx:279
void clear()
Definition: imagecontainer.hxx:691
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
void swap(const ImagePyramid< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:763
iterator end()
Definition: imagecontainer.hxx:613
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:521
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:500
int highestLevel() const
Definition: imagecontainer.hxx:573
void resize(size_type newSize)
Definition: imagecontainer.hxx:310
void pop_back()
Definition: imagecontainer.hxx:374
reverse_iterator rbegin()
Definition: array_vector.hxx:251
int lowestLevel() const
Definition: imagecontainer.hxx:566
const_iterator end() const
Definition: array_vector.hxx:237
size_type size() const
Definition: array_vector.hxx:330
reference operator[](size_type index)
Definition: imagecontainer.hxx:581
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:748
Class template for logarithmically tapering image pyramids.
Definition: imagecontainer.hxx:465
virtual void resizeImages(const Diff2D &newSize)
Definition: imagecontainer.hxx:418
const_iterator begin() const
Definition: imagecontainer.hxx:605
size_type capacity() const
Definition: imagecontainer.hxx:393
const_reference front() const
Definition: imagecontainer.hxx:741
const_reverse_iterator rbegin() const
Definition: imagecontainer.hxx:639
iterator insert(iterator pos, const_reference image)
Definition: imagecontainer.hxx:263
const_iterator begin() const
Definition: imagecontainer.hxx:168