maxxy
The maxxy function returns the maximum value and coordinates of the maximum value for a 1-dimensional array, CImage, or list of numbers. This function is similar to the CStat:Max method but does not require calling new_stats() beforehand to create a CStats object. The related max function returns only the maximum value. The maxn function returns the maximum value in a general n-dimensional table.
nMax, nX, nY = maxxy( 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.
nMax is the maximum value found in Data.
nX and nY are the coordinates of the maximum value, starting at 1.
If Data is a 1-dimensional array or the CImage has 1 dimension, the value of nY is returned as 1.
The CImage class supports values ranging from byte to double plus other pixel types.
For a CMatrix, the returned nX and nY can be difficult to untangle because the CMatrix does not require a fixed number of columns in each row.
The following script returns the maximum value of a table containing 1 million random numbers.
|
-- create a table of numbers |
|
-- find the maximum value |
|
-- list the maximum value and coordinates |
The next script returns the maximum value and its coordinates for pixels in a CImage.
|
-- attach the topmost image window |
|
-- make sure an image window is on top |
|
-- use the current image in the CImageView |
|
-- list the maximum value and coordinates |
The next example computes the maximum value of a list of numbers:
|
-- find the maximum value |
|
-- result: Max = 8.4, 4, 1 |
Table and Array Functions, max, maxn, min
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.