CStats:SetImage


The SetImage method assigns a CImage and an optional CRect object to the CStats object. Statistics methods will measure this image and optional rectangle you specify unless a different data collection is specified in the method call (see the examples, below).

NOTE: This is a deprecated method provided only for compatibility with scripts written for MX Script version 7 or earlier. In new scripts, use the new argument list options in the CStats methods.

Syntax

CStats:SetImage( CImage )

CStats:SetImage( CImage, CRect )

where

    CImage is a CImage object to measure using CStats class methods.

    CRect is a CRect object to measure using CStats class methods. If not specified, the entire image is measured.

Examples

his example uses SetImage to define a CImage I and CRect R for measurement (both are preseumed to already exist). The following script measures various statistics for the same image and rectangle:

S = CStats:new()

-- create a CStats object

S:SetImage( I, R )

-- specify the image and rectangle to be measured

mean, sdev = S:MeanSdev()

-- return the mean and standard deviation

contra = S:ContraMean()

-- return the contra mean for power 0.5

rank = S:Rank( 40 )

-- return the 40th rank percentile.

The next example uses SetImage to define a CImage I for measurement. Since no CRect is defined, the entire image is measured:

S = CStats:new()

-- create a CStats object

S:SetImage( I )

-- specify the image to be measured

mean, sdev = S:MeanSdev()

-- return the mean and standard deviation

contra = S:ContraMean()

-- return the contra mean for power 0.5

rank = S:Rank( 40 )

-- return the 40th rank percentile.

The following script shows the new, preferred way to compute statistics without using SetImage to define the CImage and CRect:

I = CImage:new()

-- create an image

R = NewRect(10,40, 100,250)

-- create a rectangle

   --

-- do something

S = CStats:new()

-- create a CStats object

mean, sdev = S:MeanSdev( I )

-- measure the entire image I

contra = S:ContraMean( I, R, 0.5 )

-- measure I inside rectangle R

rank = S:Rank( I, R, 40 )

-- measure I inside rectangle R

rank2 = S:MeanSdev( {1,2,3,4,5.2} )

-- measure a lua table

Related Topics

CStats Class