CStats:MaxPix


The MaxPix method returns the pixel coordinate of the maximum value of 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. If the sample is a CImage, the position is a pixel location considered in 1 dimension.

Syntax

nPix = CStats:MaxPix( table )

nPix = CStats:MaxPix( CImage, )

nPix = CStats:MaxPix( CImage, CRect )

nPix = CStats:MaxPix( CArray )

nPix = CStats:MaxPix( CArray, CRect )

nPix = CStats:MaxPix( 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 sample.

    nPix is the integral position of the data member of maximum value, starting at position 1. On failure, 0 is returned.

Example

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

S = CStats:new()

-- create a CStats object

n = S:MaxPix( I, R )

-- get the column and row of the maximum value

Printf("Max at position %d\n", n )

-- list the result

Related Topics

Max

MinPix

CStats Class