[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

| CrackContourCirculator Class Template Reference |
--- | --- | ---

Circulator that walks around a given region. More...

`#include "vigra/contourcirculator.hxx"`

## Public Types

typedef Point2D | value_type
typedef Point2D const & | reference
typedef Point2D const * | pointer
typedef forward_circulator_tag | iterator_category

## Public Methods

| CrackContourCirculator (IMAGEITERATOR const &in_the_region, vigra::FourNeighborCode::Direction dir=vigra::FourNeighborCode::West)
CrackContourCirculator & | operator++ ()
CrackContourCirculator | operator++ (int)
bool | operator== (CrackContourCirculator const &o) const
bool | operator!= (CrackContourCirculator const &o) const
reference | pos () const
reference | operator * () const
pointer | operator-> () const
IMAGEITERATOR | outerPixel () const
Diff2D const & | diff () const

## Detailed Description

### template<class IMAGEITERATOR>
class vigra::CrackContourCirculator< IMAGEITERATOR >

Circulator that walks around a given region.

The circulator follows the crack contour of a given region. Here, a region is an 8-connected component of pixels with the same value, such as the regions in a label image. The crack contour is located between the inside and outside pixels, that is "on the crack" between the region and the background. Thus, the circulator moves from pixel corner to pixel corner. By definition, the first corner (where the circulator was initialized) gets the coordinate (0,0), and calls to `*circulator` return the distance of the current corner to the initial one.

The circulator can be used to calculate the area of a region (in pixels):

        // start with a pixel within the region, whose left neighbor is outside
        // (see CrackContourCirculator constructor)
        ImageIterator region_anchor = ...;
        int area = 0;

        // calculate area from following the crack contour of the region
        CrackContourCirculator<ImageIterator> crack(region_anchor);
        CrackContourCirculator<ImageIterator> crackend(crack);
        do
        {
            area += crack.diff().x * crack.pos().y -
                    crack.diff().y * crack.pos().x;
        }
        while(++crack != crackend);

        area /= 2;
        std::cout << "Area of region " << *region_anchor << ": " << area << std::endl;

#include "vigra/contourcirculator.hxx"
Namespace: vigra

## Member Typedef Documentation

typedef forward_circulator_tag iterator_category

| the circulator tag

typedef Point2D const* pointer

| the circulator's pointer type (return type of `operator->`)

typedef Point2D const& reference

| the circulator's reference type (return type of `*circ`)

typedef Point2D value_type

| the circulator's value type

## Constructor & Destructor Documentation

CrackContourCirculator | ( | IMAGEITERATOR const & | in_the_region,
|  | vigra::FourNeighborCode::Direction | dir = vigra::FourNeighborCode::West
| ) | `[inline]`

Initialize the circulator for a given region.

The image iterator `in_the_region` must refer to a boundary pixel of the region to be analysed. The direction code `dir` must point to a pixel outside the region (the default assumes that the pixel left of the given region pixel belongs to the background). The first corner of the crack contour is the corner to the right of this direction (i.e. the north west corner of the region pixel, if the direction was West).

## Member Function Documentation

Diff2D const& diff | ( |  | ) | const`[inline]`

| Get the offset from the current corner of the contour to the next one.

reference operator * | ( |  | ) | const`[inline]`

| Equivalent to pos()

bool operator!= | ( | CrackContourCirculator< IMAGEITERATOR > const & | o | ) | const`[inline]`

| inequality

CrackContourCirculator operator++ | ( | int |  | ) | `[inline]`

| Move to the next crack corner of the contour (post-increment).

CrackContourCirculator& operator++ | ( |  | ) | `[inline]`

| Move to the next crack corner of the contour (pre-increment).

pointer operator-> | ( |  | ) | const`[inline]`

| Access member of the current coordinate.

bool operator== | ( | CrackContourCirculator< IMAGEITERATOR > const & | o | ) | const`[inline]`

| equality

IMAGEITERATOR outerPixel | ( |  | ) | const`[inline]`

| Access pixel to the right of the crack edge (outside of the region bounded by the crack contour we walk on). Note that after operator++, the iterator can still point to the same pixel (looking from another direction now).

reference pos | ( |  | ) | const`[inline]`

| Get the coordinate of the current corner (relative to the first corner).

The documentation for this class was generated from the following file:

- vigra/contourcirculator.hxx

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.5.0 (7 Dec 2006)