arraytoimage


The arraytoimage function copies an indexed table, or "array", into a 1- or 2-dimensional CImage object, according to the dimenionality of the table. This function's name uses "array" as a reminder that the 1-dimensional array must be indexed using numeric subscripts [], rather than named members in "name = value" pairs. A basic image header is created for the returned CImage.

Syntax

CImage_obj = arraytoimage( lua_table )

CImage_obj = arraytoimage( lua_table, strDataType )

bullet.gif    where lua_table is indexed as a 1- or 2-dimensional table (array).

bullet.gif    strDataType is a string that specifies the pixel type of pixels in the CImage. If omitted, it is assumed to be "double".

bullet.gif    CImage_obj is returned as a new CImage object.

bullet.gif    On failure, nil is returned.

Examples

The following script shows how to convert a 2-dimensional table to an image. For images of substantial dimension, the table is usually created by some other method, such as a calculation.

tbl = {}

-- create a table (this will be a 2-D table)

tbl[1] = {}

-- create the table for row 1

tbl[1][1] = 15.3

-- assign the first column in row 1

tbl[1][2] = 12.592

-- assign the second column in row 1

-- complete row 1...

 

tbl[2] = {}

-- create the table for row 2

tbl[2][1] = 15.3

-- assign the first column in row 2

tbl[2][2] = 12.592

-- assign the second column in row 2

-- complete row 2...

 

-- complete all rows

 

I = arraytoimage(tbl,"float")

-- create a CImage object I of type "float"

  

Related Topics

Table and Array Functions

CImage:ToTable


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.