CStats:Mean and CStats:MeanSdev
The Mean method computes the mean and standard deviation of a 1-dimensional array, CImage, or list of numbers. The array and list parameters must contain a mixture of numbers and strings that can be converted to numbers.
nMean = CStats:Mean( CImage, CRect )
nMean = CStats:Mean( CImage )
nMean = CStats:Mean( table )
nMean = CStats:Mean( n1, n2, n3, ... )
nMean, nSdev = CStats:MeanSdev( CImage, CRect )
nMean, nSdev = CStats:MeanSdev( CImage )
nMean, nSdev = CStats:MeanSdev( table )
nMean, nSdev = CStats:MeanSdev( n1, n2, n3, ... )
CRect is a bounding rectangle for the CImage object.
table is a 1-dimensional array containing numbers.
n1, n2, n3, ... are numbers or string values that can be converted to numbers.
On success, the mean and standard deviation are returned.
On failure, returns 0, 0.
Although this method returns two values, the mean and the standard deviation, you do not have to assign a variable to capture the standard deviation in the second returned value. For example,
|
-- create a table and fill it with values |
|
|
|
-- get the mean of table T. |
|
-- gets the mean and standard deviation of the 1-dimensional array. |
If Mean is the last function in an expression, both return value can be captured as shown in this example:
There also are global functions mean and sdev that compute the mean and standard deviation without using CStats class to be invoked in the script.
Suppose a CImage I exists. The following script returns the mean and standard deviation of 600 pixels in the corner of the image, starting at column,row = (5,8). This example shows how the parameter list with a mixture values and explicit numbers:
|
-- create a CStats object |
|
|
|
-- computes values inside the CRect |
|
-- list the result |
|
-- when done with S, delete it |
CStats class, CImage class, CRect class, mean, sdev, Stats, Skewness, Kurtosis
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.