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.
CImage_obj = arraytoimage( lua_table )
CImage_obj = arraytoimage( lua_table, strDataType )
where lua_table is indexed as a 1- or 2-dimensional table (array).
strDataType is a string that specifies the pixel type of pixels in the CImage. If omitted, it is assumed to be "double".
CImage_obj is returned as a new CImage object.
On failure, nil is returned.
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.
|
-- create a table (this will be a 2-D table) |
|
-- create the table for row 1 |
|
-- assign the first column in row 1 |
|
-- assign the second column in row 1 |
-- complete row 1... |
|
|
-- create the table for row 2 |
|
-- assign the first column in row 2 |
|
-- assign the second column in row 2 |
-- complete row 2... |
|
-- complete all rows |
|
|
-- create a CImage object I of type "float" |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.