In file AAMMathUtil.h:

## class CAAMMathUtil

Utility math/statistical methods for the AAM project.

## Inheritance:

### Public Methods

void CalcElementVar( const std::vector<CDVector> &vVectors, CDVector &varVec, CDVector* vpMean )
Calculates the variance of each component in a set of vectors.
void CumSum( const CDVector &v, CDVector &cumsum, bool normalize )
Cumulative sum of elements.
Expands a matrix to have dyadic size.
void GaussianHistogramMatching( const CDVector &v, CDVector &out, const int nbins, CDVector* gaussLUT )
Maps the distibution of v into an approximate Gaussian distribution.
void Hist( CDVector &v, const double min, const double max, CDVector &hist, const int nbins, bool normalize, bool transform )
Calculates the histogram.
void LinearStretchClamp( CDVector &v, const double x1, const double x2, const double new_min, const double new_max )
Maps a vector linearly from [x1;x2] to [new_min;new_max].
void LinearStretchMinMax( CDVector &v, const double new_min, const double new_max )
Maps a vector linearly from [min;max] to [new_min;new_max].
void MeanFilter( const CDMatrix &in, CDMatrix &out )
Performs a 3x3 mean filtering of a matrix.
double MutualInformation( const CDVector &v1, const CDVector &v2, int nbins )
Calulates the Mutual Information (MI) between two vectors.
void PseudoInv( const CDMatrix &A, CDMatrix &P )
Calculates the pseudo inverse of a matrix.
void ZeroMeanUnitLength( CDVector &v )
Normalises a vector to zero mean and unit length.

## Documentation

This is the mathematical / statistical garbage bin.

It consists of methods that for some reason haven't found its way into other (and more meaningful) classes.

All methods are static, so there is never need for an instantiation of this class.

void Hist( CDVector &v, const double min, const double max, CDVector &hist, const int nbins, bool normalize, bool transform )

Calculates the histogram of a vector within [min;max] with optional nomalization.

Parameters:
v - Input vector.
min - Value for the first bin (values lower are clamped to min).
max - Value for the last bin (values lower are clamped to max).
hist - Output histogram vector.
nbins - The number of bins. Default 256.
normalize - Optional normalization, i.e. make the histogram entries sum to 1. Default true.
transform - Optional transformation of v into 'nbins' integer intervals between [min;max]. Default false.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
1-25-2002

void CumSum( const CDVector &v, CDVector &cumsum, bool normalize )

Cumulative sum of elements.

Parameters:
v - Input vector.
cumsum - Output vector containing the cumulative sum of elements.
normalize - Optional normalization of output, i.e. cumsum[end] = 1.0. Default true.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
1-25-2002

double MutualInformation( const CDVector &v1, const CDVector &v2, int nbins )

Calulates the Mutual Information (MI) between two vectors. See e.g. C. Studholme et al. or Viola et al.

Parameters:
v1 - Signal 1.
v2 - Signal 2.
nbins - The number of bins in the single and joint histograms. Default 256.
Returns:
The Mutual Information (MI).
Author:
Mikkel B. Stegmann
Version:
1-22-2002

void GaussianHistogramMatching( const CDVector &v, CDVector &out, const int nbins, CDVector* gaussLUT )

Maps the distibution of v into an approximate Gaussian distribution.

Parameters:
v - Input vector.
out - Output vector.
nbins - Number of bins used to approx the distribution. Default 256.
gaussLUT - If not null, the calulated LUT is returned here.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
1-25-2002

This method expands a matrix to have dyadic size, i.e. nrows and ncols that are powers of two.

Parameters:
m - Input matrix.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
4-24-2002

void CalcElementVar( const std::vector<CDVector> &vVectors, CDVector &varVec, CDVector* vpMean )

Parameters:
cVectors - Input set of vectors.
varVec - A vector containing the variance of each compoment in cVectors.
vpMean - Optional vector pointer to return the mean vector in.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-22-2000

void LinearStretchMinMax( CDVector &v, const double new_min, const double new_max )

Maps a vector linearly from [min;max] to [new_min;new_max].

Parameters:
v - Input vector.
new_min - Desired minimum.
new_max - Desired maximum.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
4-25-2002
LinearStretchClamp

void LinearStretchClamp( CDVector &v, const double x1, const double x2, const double new_min, const double new_max )

Maps a vector linearly from [x1;x2] to [new_min;new_max]. Values outside [x1;x2] are clamped to x1, x2 respectively.

Parameters:
v - Input vector.
x1 - Starting point of stretch.
x2 - Ending point of stretch.
new_min - Desired minimum.
new_max - Desired maximum.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
4-25-2002
LinearStretchMinMax

void MeanFilter( const CDMatrix &in, CDMatrix &out )

Performs a 3x3 mean filtering of a matrix.

Parameters:
in - Input matrix.
out - Output mean filtered matrix.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
5-15-2002

void ZeroMeanUnitLength( CDVector &v )

Normalises a vector to zero mean and unit length.

Parameters:
v - Input vector.
Returns:
Nothing. The result is returned in v.
Author:
Mikkel B. Stegmann
Version:
6-12-2002

void PseudoInv( const CDMatrix &A, CDMatrix &P )

Calculates the pseudo inverse of a matrix.

Parameters:
A - Input matrix.
P - Pseudo inverse of A.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
7-19-2002

This class has no child classes.
Author:
Mikkel B. Stegmann
Version:
1-28-2002