CImage:Create
The Create method creates an image array of specified dimensions and datatype.
The following method creates an image having 1 pixel and data type "double": bSuccess = CImage:Create()
The following methods create an imge having a specified number of dimensions. When the data type is not specified, it defaults to type "double". bSuccess = CImage:Create( Dim[] ) bSuccess = CImage:Create( Dim[], sDatatype ) The following methods are deprecated in this version of MX Script and should not be used in future scripts: bSuccess = CImage:Create( nCols ) bSuccess = CImage:Create( nCols, sDatatype ) bSuccess = CImage:Create( nCols, nRows ) bSuccess = CImage:Create( nCols, nRows, sDatatype ) bSuccess = CImage:Create( nCols, nRows, nPlanes ) bSuccess = CImage:Create( nCols, nRows, nPlanes, sDatatype ) where |
nDim[] is an array containing the lengths of the image axes. The number of axis must be between 1 and the maximum number supported by Mira. For example, { 1024, 512, 64 } creates a 3-D image having 1024 columns, 512 rows, and 64 planes.
sDataType is the datatype (e.g., "byte").
nCols is the number of columns in the image.
nRows is the number of rows in the image if 2 dimensional.
nPlanes is the number of planes in the image if 3 dimensional.
sDatatype is a string that describes the image data type (e.g., "16 bit unsigned").
bSuccess is the returned success code. On success it is true, otherwise false.
The image is created with the pixel values set to 0. You can change all, most, or some of the pixel values using the SetRegionVal and Set methods. If no arguments are provided, then an image is created with a single pixel of type "double". Use this method when you want to apply an image method to a single number (the image pixel).
Mira supports images having dimensions up to 10 dimensions. To specify more than 3 dimnsions you must use the form with tDim as an argument. In the dimension table, the number of columns is table element 1, number of rows is table element 2, and so on. For example, an image having 100 columns, 200 rows, and 300 planes would be created using a dimension table like tDim = { 100, 200, 300 }.
The following script creates a 2-dimensional image of type unsigned 16 bit integer ("ushort"):
|
-- create a CImage object |
|
-- Create a 2-D, 100x200 image of type "ushort" |
|
-- if not created, then exit the script |
|
-- set all the pixel values to 2000. |
The following example show how to create having image with 4 dimensions. This image has 6 groups of 16 planes of 256 rows and 100 columns:
|
-- create a table of axis dimensions |
|
-- create a CImage object |
|
-- Create a 100x256x16 image of type "float" |
|
-- if not created, then exit the script |
|
-- set all the pixel values to 2000. |
Note that we also could create the same image like this:
|
-- create a CImage of 100x256x16 |