CStats:Max


The Max method computes the maximum value for a data sample. The sample may be a Lua table or a class object of type CImage, CArray, or CMatrix. For CImage and CMatrix objects, an optional CRect object can be used to define the points used in the calculation.

Syntax

nMax = CStats:Max( table )

nMax = CStats:Max( CImage, )

nMax = CStats:Max( CImage, CRect )

nMax = CStats:Max( CArray )

nMax = CStats:Max( CArray, CRect )

nMax = CStats:Max( CMatrix )

where

    table is a lua table containing the data.

    CImage, CArray, and CMatrix are class objects containing the data to measure,

    CRect is a CRect rectangle object that defines the region to measure.

    nMax is the maximum value of the data. On failure, 0 is returned.

Examples

Suppose that CImage object I and CRect object R exist. The following script returns the maximum value inside a rectangle on the image:

S = CStats:new()

-- create a CStats object

nVal = S:Max( I, R )

-- returns the maximum value

Printf("Max=%lg\n", nVal)

-- list the result

The following script returns the maximum value in a table of data:

S = CStats:new()

-- create a CStats object

t = { 4, 4, 2, 5, 6.4, -1.42, -12, 3.4 }

-- create some data in a table

Printf("max=%lg\n", S:Max(t) )

-- list the result

Related Topics

MaxPix

Min

CStats Class