CStats:Mean
The Mean method computes the mean and standard deviation of numeric data. The data may be in the form of a lua array or a class object of type CImage, CArray, or CMatrix. For the CImage and CMatrix classes, you can optionally specify a rectangle that bounds the data region. For a CImage, the data may have multiple channels as with an RGB image.
nMean, nSdev = CStats:Mean( Data, CRect* )
nMr,nSr, nMg,nMg, nMb,nMb = CStats:Mean( CImage, CRect* )
Although this method returns two values, the mean and the standard deviation, you do not have to "catch" the standard deviation by assigning to a variable. For example,
|
-- get the mean of table T. |
|
-- gets the mean and standard deviation of table T. |
If Mean is the last function in an expression, both values can be used implicitly, like
Suppose a CImage I exists. The following script returns the mean and standard deviation of 600 pixels in the corner of the image:
|
-- create a CStats object |
|
-- computes values inside the CRect |
|
-- list the result |
|
-- when done with S, delete it |