CStats:ContraMean and CStats:ContraMeanSdev


The ContraMean method computes the contra-harmonic mean estimator to reduce the influence of deviant pixels.

Syntax

nMean = CStats:ContraMean( CImage, nExp, CRect )

nMean = CStats:ContraMean( CImage, nExp )

nMean = CStats:ContraMean( table, nExp )

nMean, nSdev = CStats:ContraMeanSdev( CImage, nExp, CRect )

nMean, nSdev = CStats:ContraMeanSdev( CImage, nExp )

nMean, nSdev = CStats:ContraMeanSdev( table, nExp )

bullet.gif    The CRect is a bounding rectangle for the CImage object.

bullet.gif    nExp specifies the exponent parameter of the harmonic mean.

bullet.gif    On success, returns the contra-harmonic mean value and standard deviation.

bullet.gif    On failure, returns 0, 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

bullet.gif    e=0 gives the arithmetic mean.

bullet.gif    e<0 gives more weight to negative outliers.

bullet.gif    e>0 gives more weight to positive outliers.

Example

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

S = new_stats()

-- create a CStats object

-- specify CImage and CRect to measure

 

power = 0.5

-- reduce the weight of negative outliers

nVal = S:ContraMean(I, power, R)

-- 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 class, CImage class, CRect class, GeometricMean, YpMean


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.