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

| ArrayOfRegionStatistics [Functors To Inspect Images] |

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

`#include <vigra/inspectimage.hxx>`

List of all members.

## Public Types
typedef LabelType | argument_type
typedef RegionArray::const_iterator | const_iterator
typedef RegionStatistics const & | const_reference
typedef RegionStatistics::argument_type | first_argument_type
typedef RegionArray::iterator | iterator
typedef RegionStatistics & | reference
typedef RegionStatistics::result_type | result_type
typedef LabelType | second_argument_type
typedef RegionStatistics | value_type
## Public Member Functions
| ArrayOfRegionStatistics (unsigned int max_region_label)
| ArrayOfRegionStatistics ()
const_iterator | begin () const
iterator | begin ()
const_iterator | end () const
iterator | end ()
unsigned int | maxRegionLabel () const
void | merge (argument_type label1, argument_type label2)
result_type | operator() (argument_type label) const
void | operator() (first_argument_type const &v, second_argument_type label)
reference | operator[] (argument_type label)
const_reference | operator[] (argument_type label) const
void | reset ()
void | resize (unsigned int max_region_label)
unsigned int | size () 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 | ( |  | ) |

init array of RegionStatistics with default size 0.

ArrayOfRegionStatistics | ( | unsigned int | max_region_label | ) |

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

## Member Function Documentation

const_iterator begin | ( |  | ) | const

const iterator to the begin of the region array

iterator begin | ( |  | ) |

iterator to the begin of the region array

const_iterator end | ( |  | ) | const

const iterator to the end of the region array

iterator end | ( |  | ) |

iterator to the end of the region array

unsigned int maxRegionLabel | ( |  | ) | const

ask for maximal index (label) allowed

void merge | ( | argument_type | label1,
|  | argument_type | label2 |
| ) |  |  |

merge second region into first

result_type operator() | ( | argument_type | label | ) | const

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 |
| ) |  |  |

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

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

access the statistics functor for a region via its label

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

read the statistics functor for a region via its label

void reset | ( |  | ) |

reset the contained functors to their initial state.

void resize | ( | unsigned int | max_region_label | ) |

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

unsigned int size | ( |  | ) | const

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 (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.7.1 (3 Dec 2010)