CStats:ContraMean and CStats:ContraMeanSdev
The ContraMean method computes the contra-harmonic mean estimator to reduce the influence of deviant pixels.
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 ) |
The CRect is a bounding rectangle for the CImage object.
nExp specifies the exponent parameter of the harmonic mean.
On success, returns the contra-harmonic mean value and standard deviation.
On failure, returns 0, 0.
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.
Suppose a CImage I and a CRect R exist. The following script returns the contra-mean value inside a rectangle on the image:
|
-- create a CStats object |
-- specify CImage and CRect to measure |
|
|
-- reduce the weight of negative outliers |
|
-- return the contra-harmonic mean value |
|
-- list the result |
|
-- when done with S, remove it from memory |
CStats class, CImage class, CRect class, GeometricMean, YpMean
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.