CStats:Sum
The Sum method computes the sum of a 1-dimensional array, CImage, or list of numbers. Compared with the Mean and several other class methods, this does not return the standard deviation. The array and list parameters must contain a mixture of numbers and strings that can be converted to numbers.
nSum = CStats:Sum( CImage, CRect )
nSum = CStats:Sum( CImage )
nSum = CStats:Sum( table )
nSum = CStats:Sum( n1, n2, n3, ... )
CRect is a bounding rectangle for the CImage object.
table is a 1-dimensional array containing numbers.
n1, n2, n3, ... may be a mixture of numbers and strings that can be converted to numbers.
On success, returns the sum of the data.
On failure, returns 0.
In these examples, note the use of both S and s; these are independent variables because lua is case-sensitive.
|
-- create a table and fill it with values |
|
|
|
-- calculate the sum of a 1-dimensional array. |
There is also a global function sum that computes the sum without using the CStats class.
Suppose a CImage I exists. The following script returns the sum 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 |
CStats class, CImage class, CRect class, Mean, sum, Stats, Skewness, Kurtosis
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.