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

| ArrayOfRegionStatistics Class Template Reference |
--- | --- | ---

Calculate statistics for all regions of a labeled image. More...

`#include "vigra/inspectimage.hxx"`

## Public Types

typedef RegionStatistics::argument_type | first_argument_type
typedef LabelType | second_argument_type
typedef LabelType | argument_type
typedef RegionStatistics::result_type | result_type
typedef RegionStatistics | value_type
typedef RegionStatistics & | reference
typedef RegionStatistics const & | const_reference
typedef RegionArray::iterator | iterator
typedef RegionArray::const_iterator | const_iterator

## Public Methods

| ArrayOfRegionStatistics ()
| ArrayOfRegionStatistics (unsigned int max_region_label)
void | resize (unsigned int max_region_label)
void | reset ()
void | operator() (first_argument_type const &v, second_argument_type label)
void | merge (argument_type label1, argument_type label2)
unsigned int | maxRegionLabel () const
unsigned int | size () const
result_type | operator() (argument_type label) const
const_reference | operator[] (argument_type label) const
reference | operator[] (argument_type label)
iterator | begin ()
const_iterator | begin () const
iterator | end ()
const_iterator | end () const

## Detailed Description

### template<class RegionStatistics, class LabelType = int>
class vigra::ArrayOfRegionStatistics< RegionStatistics, LabelType >

Calculate statistics for all regions of a labeled image.

This Functor encapsulates an array of statistics functors, one for each label, and selects the one to be updated according to the pixel's label.

Traits defined:

`FunctorTraits::isBinaryAnalyser` and `FunctorTraits::isUnaryFunctor` are true (`VigraTrueType`)``

Usage:

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

        vigra::BImage img;
        vigra::IImage labels;
        int max_label;
        ...

        // init functor as an array of 'max_label' FindMinMax-Functors
        vigra::ArrayOfRegionStatistics<vigra::FindMinMax<vigra::BImage::PixelType> >
                                                             minmax(max_label);

        vigra::inspectTwoImages(srcImageRange(img), srcImage(labels), minmax);

        for(int i=0; i<= max_label; ++i)
        {
            cout << "Max gray lavel of region " << i << ": "
                 << minmax.region[i].max << endl;
        }

        // init functor as an array of 'max_label' FindAverage-Functors
        vigra::ArrayOfRegionStatistics<vigra::FindAverage<vigra::BImage::PixelType> >
                                                             average(max_label);

        vigra::inspectTwoImages(srcImageRange(img), srcImage(labels), average);

        // write back the average of each region into the original image
        vigra::transformImage(srcImageRange(labels), destImage(img), average);

Required Interface:

        RegionStatistics region;
        RegionStatistics::argument_type a;
        RegionStatistics::result_type r;

        region(a);     // update statistics
        r = region();  // return statistics

Examples:

  voronoi.cxx, and watershed.cxx.

## Member Typedef Documentation

typedef LabelType argument_type

| label type is also used to determine the region to be returned by the 1 argument operator()

typedef RegionArray::const_iterator const_iterator

| type to iterate over a const statistics array

typedef RegionStatistics const& const_reference

| the array's const reference type

typedef RegionStatistics::argument_type first_argument_type

| argument type of the contained statistics object becomes first argument of the analyser

typedef RegionArray::iterator iterator

| type to iterate over the statistics array

typedef RegionStatistics& reference

| the array's reference type

typedef RegionStatistics::result_type result_type

| result type of the contained statistics object becomes result type of the analyser

typedef LabelType second_argument_type

| label type is used to determine the region to be updated

typedef RegionStatistics value_type

| the value type of the array: the contained statistics object. Note: this definition was different in older VIGRA versions. The old definition was wrong.

## Constructor & Destructor Documentation

ArrayOfRegionStatistics | ( |  | ) | `[inline]`

| init array of RegionStatistics with default size 0.

ArrayOfRegionStatistics | ( | unsigned int | max_region_label | ) | `[inline]`

| init array of RegionStatistics with index domain 0...max_region_label.

## Member Function Documentation

const_iterator begin | ( |  | ) | const`[inline]`

| const iterator to the begin of the region array

iterator begin | ( |  | ) | `[inline]`

| iterator to the begin of the region array

const_iterator end | ( |  | ) | const`[inline]`

| const iterator to the end of the region array

iterator end | ( |  | ) | `[inline]`

| iterator to the end of the region array

unsigned int maxRegionLabel | ( |  | ) | const`[inline]`

| ask for maximal index (label) allowed

void merge | ( | argument_type | label1,
|  | argument_type | label2
| ) | `[inline]`

| merge second region into first

result_type operator() | ( | argument_type | label | ) | const`[inline]`

| access the statistics for a region via its label. The label type is converted to `unsigned int`.

void operator() | ( | first_argument_type const & | v,
|  | second_argument_type | label
| ) | `[inline]`

| update regions statistics for region `label`. The label type is converted to `unsigned int`.

reference operator[] | ( | argument_type | label | ) | `[inline]`

| access the statistics functor for a region via its label

const_reference operator[] | ( | argument_type | label | ) | const`[inline]`

| read the statistics functor for a region via its label

void reset | ( |  | ) | `[inline]`

| reset the contained functors to their initial state.

void resize | ( | unsigned int | max_region_label | ) | `[inline]`

| resize array to new index domain 0...max_region_label. All bin are re-initialized.

unsigned int size | ( |  | ) | const`[inline]`

| ask for array size (i.e. maxRegionLabel() + 1)

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

- vigra/inspectimage.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)