CImage:new
The new method constructs a new instance of a CImage object. To create a new CImage object initialized to values in a lua array (table), use the newarray constructor.
|
The default constructor creates an empty image with no dimensions and containing no data. Following this method, use Create, Open, or another method to place data into the image: CImageNew = CImage:new() CImageNew = CImage:new( CImage2 ) CImageNew = CImage:new( CMatrix ) CImageNew = CImage:new( nDim[], sDataType ) The following 2 constructors are deprecated in this version of MX Script and should not be used in future scripts. Instead of these methods, use the general form for nDim[] dimensions: CImageNew = CImage:new( nCols, sDataType ) CImageNew = CImage:new( nCols, nRows, sDataType ) where |
CImage2 is an existing CImage
object.
CMatrix is a CMatrix object having 1 or 2 dimensions.
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 a string specifying the datatype of the image (e.g.,
"byte", "float", etc.).
nCols is the number of columns in a 1-D or 2-D
image (deprecated).
nRows is the number of rows in a 2-D image
(deprecated).
CImageNew is the return value, a new
CImage object.
Other contructors are provided to create a new image with a specified dimension and datatype. The new image can be filled in various ways such as by using the Create method, setting values using the Set method, or using Open on a file. Also see the "=" operator and Copy method as a way to create a new CImage from another CImage.
If you pass no arguments, a default CImage is created with 1 pixel of type "double". Whithout further extending the default CImage class, it can be useful if there are CImage methods you want to apply to a numeric value. Use CImage:Set to set the value, then perform the operations on it.
The following script creates a CImage object and loads an image into it. Then it creates a new CImage that is a duplicate of the first one. This makes 2 images loaded into memory:
|
|
-- create a new CImage object |
|
|
-- load an image from a file |
|
|
-- create a new CImage with a copy of A |
|
|
-- print the name of image A |
|
|
-- print the name of image B (is same as A) |
The following script creates a 3 dimensional image of "float" data type and sets all pixels to value 1000.0:
|
|
-- create a new 3-D CImage object of "float" type |
|
|
-- assign the value 1000 to all pixels |
|
|
-- prints "Axes = 3" |
|
|
-- for each image axis |
|
|
-- prints Len[1]=100 Len[2]=256 Len[3] =10 |
|
|
|