36 #ifndef VIGRA_IMAGECONTAINER_HXX
37 #define VIGRA_IMAGECONTAINER_HXX
39 #include "utilities.hxx"
40 #include "array_vector.hxx"
41 #include "copyimage.hxx"
71 template <
class ImageType,
72 class Alloc =
typename ImageType::allocator_type::template rebind<ImageType>::other >
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())
102 : imageSize_(imageSize),
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>
135 : imageSize_(begin!=end? (*begin).
size() :
Size2D(0,0)),
136 images_(begin, end, alloc)
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();
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>
278 void insert(iterator pos, InputIterator begin, InputIterator end)
280 images_.insert(pos, begin, end);
288 return images_.erase(pos);
294 iterator
erase(iterator begin, iterator end)
296 return images_.erase(begin, end);
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++)
465 template <
class ImageType,
466 class Alloc =
typename ImageType::allocator_type::template rebind<ImageType>::other >
469 int lowestLevel_, highestLevel_;
480 typedef typename ImageVector::iterator iterator;
481 typedef typename ImageVector::const_iterator const_iterator;
482 typedef typename ImageVector::reverse_iterator reverse_iterator;
483 typedef typename ImageVector::const_reverse_iterator const_reverse_iterator;
484 typedef typename ImageVector::reference reference;
485 typedef typename ImageVector::const_reference const_reference;
486 #if !defined(_MSC_VER) || _MSC_VER >= 1300
487 typedef typename ImageVector::pointer pointer;
489 typedef typename ImageVector::difference_type difference_type;
490 typedef int size_type;
503 const Diff2D &imageSize,
int sizeAppliesToLevel = 0,
504 Alloc
const & alloc = Alloc())
505 : lowestLevel_(0), highestLevel_(-1),
508 resize(lowestLevel, highestLevel, imageSize, sizeAppliesToLevel);
524 const ImageType &image,
int copyImageToLevel = 0,
525 Alloc
const & alloc = Alloc())
526 : lowestLevel_(0), highestLevel_(-1),
529 resize(lowestLevel, highestLevel, image.size(), copyImageToLevel);
530 copyImage(srcImageRange(image), destImage((*
this)[copyImageToLevel]));
545 template <
class SrcIterator,
class SrcAccessor>
547 SrcIterator ul, SrcIterator lr, SrcAccessor src,
548 int copyImageToLevel = 0,
549 Alloc
const & alloc = Alloc())
550 : lowestLevel_(0), highestLevel_(-1),
553 resize(lowestLevel, highestLevel, lr - ul, copyImageToLevel);
554 copyImage(srcIterRange(ul, lr, src), destImage((*
this)[copyImageToLevel]));
560 : lowestLevel_(0), highestLevel_(-1),
577 return highestLevel_;
585 return images_[index - lowestLevel_];
593 return images_[index - lowestLevel_];
601 return images_.
begin();
609 return images_.
begin();
617 return images_.
end();
623 const_iterator
end()
const
625 return images_.
end();
652 return images_.
rend();
659 const_reverse_iterator
rend()
const
661 return images_.
rend();
669 return images_.
size();
677 return images_.
empty();
687 return (lowestLevel_ == other.lowestLevel_) && (highestLevel_ == other.highestLevel_) &&
688 (images_ == other.images_);
705 void resize(
int lowestLevel,
int highestLevel,
706 const Diff2D &imageSize,
int sizeAppliesToLevel = 0)
708 vigra_precondition(lowestLevel <= highestLevel,
709 "ImagePyramid::resize(): lowestLevel <= highestLevel required.");
710 vigra_precondition(lowestLevel <= sizeAppliesToLevel && sizeAppliesToLevel <= highestLevel,
711 "ImagePyramid::resize(): sizeAppliesToLevel must be between lowest and highest level (inclusive).");
713 ImageVector images(highestLevel - lowestLevel + 1, ImageType());
715 images[sizeAppliesToLevel -
lowestLevel].resize(imageSize);
718 unsigned int w = (images[i - 1 -
lowestLevel].width() + 1) / 2;
719 unsigned int h = (images[i - 1 -
lowestLevel].height() + 1) / 2;
722 for(
int i=sizeAppliesToLevel - 1; i>=
lowestLevel; --i)
724 unsigned int w = 2*images[i + 1 -
lowestLevel].width() - 1;
725 unsigned int h = 2*images[i + 1 -
lowestLevel].height() - 1;
729 images_.swap(images);
738 return images_.
front();
745 return images_.
front();
752 return images_.
back();
759 return images_.
back();
767 images_.swap(other.images_);
768 std::swap(lowestLevel_, other.lowestLevel_);
769 std::swap(highestLevel_, other.highestLevel_);
777 #endif // VIGRA_IMAGECONTAINER_HXX
Size2D imageSize() const
Definition: imagecontainer.hxx:412
const_reference front() const
Definition: imagecontainer.hxx:347
reference back()
Definition: array_vector.hxx:293
Fundamental class template for arrays of equal-sized images.
Definition: imagecontainer.hxx:73
reverse_iterator rbegin()
Definition: imagecontainer.hxx:632
const_reference back() const
Definition: imagecontainer.hxx:757
ImagePyramid(int lowestLevel, int highestLevel, SrcIterator ul, SrcIterator lr, SrcAccessor src, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:546
void insert(iterator pos, InputIterator begin, InputIterator end)
Definition: imagecontainer.hxx:278
void resize(size_type newSize, ImageType &image)
Definition: imagecontainer.hxx:328
void clear()
Definition: imagecontainer.hxx:301
ImageType value_type
Definition: imagecontainer.hxx:478
const_reverse_iterator rend() const
Definition: imagecontainer.hxx:659
bool empty() const
Definition: array_vector.hxx:323
size_type size() const
Definition: imagecontainer.hxx:667
const_iterator end() const
Definition: imagecontainer.hxx:185
const_iterator begin() const
Definition: array_vector.hxx:223
iterator erase(iterator begin, iterator end)
Definition: imagecontainer.hxx:294
const_iterator end() const
Definition: imagecontainer.hxx:623
ImagePyramid(Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:559
void push_back(const_reference image)
Definition: imagecontainer.hxx:368
reverse_iterator rend()
Definition: array_vector.hxx:265
reference front()
Definition: imagecontainer.hxx:736
Two dimensional difference vector.
Definition: diff2d.hxx:185
ImageType value_type
Definition: imagecontainer.hxx:84
const_reference back() const
Definition: imagecontainer.hxx:361
bool operator==(const ImagePyramid< ImageType, Alloc > &other) const
Definition: imagecontainer.hxx:685
iterator begin()
Definition: imagecontainer.hxx:161
reference operator[](size_type index)
Definition: imagecontainer.hxx:145
bool empty()
Definition: imagecontainer.hxx:675
iterator begin()
Definition: imagecontainer.hxx:599
Two dimensional size object.
Definition: diff2d.hxx:482
bool empty()
Definition: imagecontainer.hxx:246
ImageArray(unsigned int numImages, const Diff2D &imageSize, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:100
reverse_iterator rend()
Definition: imagecontainer.hxx:650
void resize(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0)
Definition: imagecontainer.hxx:705
reference back()
Definition: imagecontainer.hxx:354
ImageArray(unsigned int numImages=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:113
bool operator==(const ImageArray< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:256
reference front()
Definition: imagecontainer.hxx:340
reference front()
Definition: array_vector.hxx:279
ImageArray(InputIterator begin, InputIterator end, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:134
void clear()
Definition: imagecontainer.hxx:693
void resizeImages(int width, int height)
Definition: imagecontainer.hxx:436
size_type size() const
Definition: imagecontainer.hxx:229
void swap(const_reference other)
Definition: imagecontainer.hxx:383
const_reverse_iterator rbegin() const
Definition: imagecontainer.hxx:203
void copyImage(...)
Copy source image into destination image.
reverse_iterator rend()
Definition: imagecontainer.hxx:212
void swap(const ImagePyramid< ImageType, Alloc > &other)
Definition: imagecontainer.hxx:765
iterator end()
Definition: imagecontainer.hxx:615
void reserve(size_type n)
Definition: imagecontainer.hxx:401
ImagePyramid(int lowestLevel, int highestLevel, const ImageType &image, int copyImageToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:523
ImageArray(unsigned int numImages, const ImageType &image, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:122
size_type max_size() const
Definition: imagecontainer.hxx:238
const_reverse_iterator rend() const
Definition: imagecontainer.hxx:221
ImagePyramid(int lowestLevel, int highestLevel, const Diff2D &imageSize, int sizeAppliesToLevel=0, Alloc const &alloc=Alloc())
Definition: imagecontainer.hxx:502
int highestLevel() const
Definition: imagecontainer.hxx:575
void resize(size_type newSize)
Definition: imagecontainer.hxx:311
void pop_back()
Definition: imagecontainer.hxx:375
reverse_iterator rbegin()
Definition: array_vector.hxx:251
int lowestLevel() const
Definition: imagecontainer.hxx:568
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:583
iterator erase(iterator pos)
Definition: imagecontainer.hxx:286
iterator end()
Definition: imagecontainer.hxx:177
reverse_iterator rbegin()
Definition: imagecontainer.hxx:194
reference back()
Definition: imagecontainer.hxx:750
Class template for logarithmically tapering image pyramids.
Definition: imagecontainer.hxx:467
virtual void resizeImages(const Diff2D &newSize)
Definition: imagecontainer.hxx:419
const_iterator begin() const
Definition: imagecontainer.hxx:607
size_type capacity() const
Definition: imagecontainer.hxx:394
const_reference front() const
Definition: imagecontainer.hxx:743
const_reverse_iterator rbegin() const
Definition: imagecontainer.hxx:641
iterator insert(iterator pos, const_reference image)
Definition: imagecontainer.hxx:264
const_iterator begin() const
Definition: imagecontainer.hxx:169