sum (replaces TSum)
The sum function returns the sum of a CImage, a 1-dimensional array, or a list of numbers. The array and list parameters must contain a mixture of numbers and strings that can be converted to numbers. This function is similar to the CStat:Sum method but does not require calling new_stats() beforehand to create a CStats object.
nSum = sum( Data )
Data is a 1-dimensional array, list of numbers, or a CImage object.
n1, n2, n3, ... are numbers or string values that can be converted to numbers.
nSum is the sum of the data.
The CImage class supports values ranging from byte to double plus other pixel types.
The following script returns the sum of a table containing 1 million random numbers.
|
-- create a table of numbers |
|
-- find the sum |
|
-- list the result |
The next script returns the sum value for pixels inside a rectangle at the corner of a CImage.
|
-- attach the topmost image window |
|
-- make sure an image window is on top |
|
-- rectangle for corner of image |
|
-- use the current image in the CImageView |
|
-- list the result |
The next example computes the sum of a list of numbers:
|
-- find the sum |
|
-- result: Max = 14.4 |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.