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

| FindAverageAndVariance< VALUETYPE > Class Template Reference Functors To Inspect Images |

Find the average pixel value and its variance in an image or ROI. More...

`#include <vigra/inspectimage.hxx>`

## Public Types

typedef VALUETYPE | argument_type
typedef VALUETYPE | first_argument_type
typedef NumericTraits< VALUETYPE >::RealPromote | result_type
typedef double | second_argument_type
typedef NumericTraits< VALUETYPE >::RealPromote | value_type

## Public Member Functions

result_type | average () const
unsigned int | count () const
| FindAverageAndVariance ()
void | operator() (argument_type const &v)
void | operator() (first_argument_type const &v, second_argument_type weight)
void | operator() (FindAverageAndVariance const &v)
result_type | operator() () const
void | reset ()
result_type | variance (bool unbiased=false) const

## Detailed Description

### template<class VALUETYPE>
class vigra::FindAverageAndVariance< VALUETYPE >

Find the average pixel value and its variance in an image or ROI.

This Functor uses West's algorithm to accumulate highly accurate values for the mean and the sum of squared differences of all values seen so far (the naive incremental algorithm for the computation of the sum of squares produces large round-off errors when the mean is much larger than the standard deviation of the data.) This Functor can also be used in conjunction with ArrayOfRegionStatistics to find the statistics of all regions in a labeled image.

Traits defined:

`FunctorTraits::isUnaryAnalyser` and `FunctorTraits::isInitializer` are true (`VigraTrueType`)

Usage:

#include <vigra/inspectimage.hxx>
Namespace: vigra

vigra::BImage img;
vigra::FindAverageAndVariance<vigra::BImage::PixelType> averageAndVariance; // init functor
vigra::inspectImage(srcImageRange(img), averageAndVariance);
cout << "Average: " << averageAndVariance.average() << "\n";
cout << "Standard deviation: " << sqrt(averageAndVariance.variance()) << "\n";

Required Interface:

VALUETYPE v1, v2(v1);
double d;
v1 += v2;
v1 + v2;
v1 - v2;
v1 * v2;
v1 / d;
d * v1;

## Member Typedef Documentation

## ◆ argument_type

typedef VALUETYPE argument_type

the functor's argument type

## ◆ first_argument_type

typedef VALUETYPE first_argument_type

the functor's first argument type (for calls with a weight)

## ◆ second_argument_type

typedef double second_argument_type

the functor's second argument type (for calls with a weight)

## ◆ result_type

typedef NumericTraits<VALUETYPE>::RealPromote result_type

the functor's result type

## ◆ value_type

typedef NumericTraits<VALUETYPE>::RealPromote value_type

Deprecated:
  use argument_type and result_type

## Constructor & Destructor Documentation

## ◆ FindAverageAndVariance()

FindAverageAndVariance | ( |  | ) |

init average

## Member Function Documentation

## ◆ reset()

void reset | ( |  | ) |

(re-)init average and variance

## ◆ operator()() [1/4]

void operator() | ( | argument_type const & | v | ) |

update average and variance

## ◆ operator()() [2/4]

void operator() | ( | first_argument_type const & | v,
|  | second_argument_type | weight
| ) |  |

update average and variance, using weighted input. `stats(value, 1.0)` is equivalent to the unweighted call `stats(value)`, and `stats(value, 2.0)` is equivalent to two unweighted calls.

## ◆ operator()() [3/4]

void operator() | ( | FindAverageAndVariance< VALUETYPE > const & | v | ) |

merge two statistics

## ◆ count()

unsigned int count | ( |  | ) | const

return number of values (sum of weights) seen so far

## ◆ average()

result_type average | ( |  | ) | const

return current average

## ◆ variance()

result_type variance | ( | bool | unbiased = `false` | ) | const

return current variance. If `unbiased = true`, the sum of squared differences is divided by `count()-1` instead of just `count()`.

## ◆ operator()() [4/4]

result_type operator() | ( |  | ) | const

return current variance. calls `variance()`.

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.11.0