/************************************************************************/
/* */
/* Copyright 1998-2002 by Ullrich Koethe */
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
/* koethe@informatik.uni-hamburg.de or */
/* vigra@kogs1.informatik.uni-hamburg.de */
/* */
/* Permission is hereby granted, free of charge, to any person */
/* obtaining a copy of this software and associated documentation */
/* files (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, */
/* copy, modify, merge, publish, distribute, sublicense, and/or */
/* sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following */
/* conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the */
/* Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
#ifndef VIGRA_IMAGEITERATOR_HXX
#define VIGRA_IMAGEITERATOR_HXX
#include "vigra/utilities.hxx"
#include "vigra/accessor.hxx"
#include "vigra/iteratortraits.hxx"
#include "vigra/metaprogramming.hxx"
namespace vigra {
template
The following tables describe the general requirements for image iterators
and their iterator traits. The iterator implementations provided here
may be used for any image data type that stores its
data as a linear array of pixels. The array will be interpreted as a
row-major matrix with a particular width.
Requirements for Image Iterators
\htmlonly
\endhtmlonly
Local Types
\htmlonly
\endhtmlonly
Meaning
\htmlonly
\endhtmlonly
\htmlonly
\endhtmlonly
ImageIterator::value_type the underlying image's pixel type
\htmlonly
\endhtmlonly
ImageIterator::PixelType the underlying image's pixel type
\htmlonly
\endhtmlonly
ImageIterator::reference
the iterator's reference type (return type of *iter). Will be
value_type & for a mutable iterator, and convertible to
value_type const & for a const iterator.
\htmlonly
\endhtmlonly
ImageIterator::index_reference
the iterator's index reference type (return type of iter[diff]). Will be
value_type & for a mutable iterator, and convertible to
value_type const & for a const iterator.
\htmlonly
\endhtmlonly
ImageIterator::pointer
the iterator's pointer type (return type of iter.operator->()). Will be
value_type * for a mutable iterator, and convertible to
value_type const * for a const iterator.
\htmlonly
\endhtmlonly
ImageIterator::difference_type
the iterator's difference type (vigra::Diff2D)
\htmlonly
\endhtmlonly
ImageIterator::iterator_category
the iterator tag (vigra::image_traverser_tag)
\htmlonly
\endhtmlonly
ImageIterator::row_iterator the associated row iterator
\htmlonly
\endhtmlonly
ImageIterator::column_iterator the associated column iterator
\htmlonly
\endhtmlonly
ImageIterator::MoveX type of the horizontal navigator
\htmlonly
\endhtmlonly
ImageIterator::MoveY type of the vertical navigator
\htmlonly
\endhtmlonly
Operation
\htmlonly
\endhtmlonly
Result
\htmlonly
\endhtmlonly
Semantics
\htmlonly
\endhtmlonly
++i.x
i.x--void increment x-coordinate
--i.x
i.x--void decrement x-coordinate
i.x += dx ImageIterator::MoveX &
add dx to x-coordinate
i.x -= dx ImageIterator::MoveX &
subtract dx from x-coordinate
i.x - j.x int
difference of the x-coordinates of i and j
i.x = j.x ImageIterator::MoveX & i.x += j.x - i.x
i.x == i.y bool j.x - i.x == 0
i.x < j.x bool j.x - i.x > 0
++i.y
i.y++void increment y-coordinate
--i.y
i.y--void decrement y-coordinate
i.y += dy ImageIterator::MoveY &
add dy to y-coordinate
i.y -= dy ImageIterator::MoveY &
subtract dy from y-coordinate
i.y - j.y int
difference of the y-coordinates of i and j
i.y = j.y ImageIterator::MoveY & i.y += j.y - i.y
i.y == j.y bool j.y - i.y == 0
i.y < j.y bool j.y - i.y > 0
\htmlonly
\endhtmlonly
ImageIterator k(i) copy constructor
k = i ImageIterator & assignment
\htmlonly
\endhtmlonly
ImageIterator k default constructor
\htmlonly
\endhtmlonly
ImageIterator::row_iterator r(i) construction of row iterator
\htmlonly
\endhtmlonly
ImageIterator::column_iterator c(i) construction of column iterator
i += diff ImageIterator &
{ i.x += diff.x
i.y += diff.y; }
i -= diff ImageIterator &
{ i.x -= diff.x
i.y -= diff.y; }
i + diff ImageIterator
{ ImageIterator tmp(i);
tmp += diff;
return tmp; }
i - diff ImageIterator
{ ImageIterator tmp(i);
tmp -= diff;
return tmp; }
i - j ImageIterator::difference_type
{ ImageIterator::difference_type tmp(i.x - j.x, i.y - j.y);
return tmp; }
i == j bool
i.x == j.x && i.y == j.y
*i ImageIterator::reference
access the current pixel
i[diff] ImageIterator::index_reference
access pixel at offset diff
i(dx, dy) ImageIterator::index_reference
access pixel at offset (dx, dy)
i->member() depends on operation
call member function of underlying pixel type via operator-> of iterator
\htmlonly
\endhtmlonly
i, j, k are of type ImageIterator
diff is of type ImageIterator::difference_type
dx, dy are of type int
The following iterator traits must be defined for an image iterator:
| \htmlonly | \endhtmlonly Types \htmlonly | \endhtmlonly Meaning \htmlonly | \endhtmlonly
|---|---|---|
| IteratorTraits<ImageIterator>::Iterator | the iterator type the traits are referring to | |
| IteratorTraits<ImageIterator>::iterator | the iterator type the traits are referring to | |
| IteratorTraits<ImageIterator>::value_type | the underlying image's pixel type | |
| IteratorTraits<ImageIterator>::reference | the iterator's reference type (return type of *iter) | |
| IteratorTraits<ImageIterator>::index_reference | the iterator's index reference type (return type of iter[diff]) | |
| IteratorTraits<ImageIterator>::pointer | the iterator's pointer type (return type of iter.operator->()) | |
| IteratorTraits<ImageIterator>::difference_type | the iterator's difference type | |
| IteratorTraits<ImageIterator>::iterator_category | the iterator tag (vigra::image_traverser_tag) | |
| IteratorTraits<ImageIterator>::row_iterator | the associated row iterator | |
| IteratorTraits<ImageIterator>::column_iterator | the associated column iterator | |
| IteratorTraits<ImageIterator>::DefaultAccessor | the default accessor to be used with the iterator | |
| IteratorTraits<ImageIterator>::default_accessor | the default accessor to be used with the iterator | |
| IteratorTraits<ImageIterator>::hasConstantStrides | whether the iterator uses constant strides on the underlying memory (always VigraTrueType for ImageIterators). |