CStats:AlphaClipMean CStats:GeometricMean

CStats:ContraMean


The ContraMean method computes the mean value inside a rectangular region of the image using contra-harmonic mean estimation to reduce the influence of deviant pixels. This is described in the Remarks section. The rectangle and image must have been previously initialized for the CStats object.

Syntax

nMean = CStats:ContraMean( nExp )

    wherenExp specifies the exponent parameter of the harmonic mean. See Remarks.

    On success, returns the contra-harmonic mean value as a number.

    On failure, returns 0.

Remarks

This method uses the contra-harmonic mean statistic which assigns weights to values based upon their distance from the mean value. No rejection ("clipping") is performed. In contrast to the geometric mean, this method can be tuned to assign less weight to values lying above the sample or to values lying below the sample mean. The positive or negative tail bias depends upon the value of the exponent parameter and the severity of the weighting depends upon the absolute value of the exponent parameter.

For an exponent parameter of value e, the statistic is computed using a ratio of powers for each sample member x, as shown below. (Note: The symbol ^ denotes raising a number to a power, as in 2^3 = 8):

     Statistic = Sum( x^(e+1)/x^e ).

Thus

    e=0 gives the arithmetic mean.

    e<0 gives more weight to negative outliers.

    e>0 gives more weight to positive outliers.

Example

Suppose a CImage I and a CRect R exist. The following script fragment returns the contra-mean value inside a rectangle on the image:

 

S = CStats:new()

-- create a CStats object

S:Init( I, R )

-- specify CImage and CRect to measure

power = 0.5

-- reduce the weight of negative outliers

nVal = S:ContraMean(power)

-- return the contra-harmonic mean value

Printf("mean=%lg\n", nVal)

-- list the result

S:delete()

-- when done with S, remove it from memory

Related Topics

CStats, CImage, CRect, GeomMean, YpMean