ImageTools
Create
create an image
Calling Sequence
Parameters
Options
Description
Examples
Create( height, width, layers, data, opts)
height
-
(optional) {nonnegint, range(integer)}; the height of the image in pixels
width
(optional) {nonnegint, range(integer)}; the width of the image in pixels
layers
(optional) 1,3,4, 1..3, or 1..4; the layers in the image
data
(optional); data with which to initialize the image
opts
(optional) equation(s) of the form option = value; specify options for the Create command
background = color
Specifies the initial background color of the image. Valid values for color are black, white, a numeric value, and a list of 3 or 4 numeric values. 0 corresponds to black, and 1 to white. The default is black.
channels = 1, 3, or 4
Specifies the number of color channels. A value of 1 results in a monochrome image. Values of 3 and 4 produce RGB and RGBA images, respectively. The default is 1 (monochrome). If the data parameter is specified, this option is ignored.
copy = truefalse
Specifies what happens when the data parameter is already an rtable of a suitable format. If true, then a new rtable is created and the data is copied into it. If false and the order of data matches the specified order, data becomes the image rtable returned by Create. If the data is not in a form suitable to being an image rtable, a new rtable is always created, regardless of the setting of the copy option. The default is false.
format = Array or Matrix
Specifies whether the created image is an Array or Matrix. A Matrix is possible only for grayscale images. The default is Array.
order = C_order or Fortran_order
Specifies how the data is stored in memory. See Fortran_order. Unlike rtable, the default is C_order.
datatype = float[8] or integer[1]
By default, images produced are built using 64-bit floating point values. If the extremen accuracy is not required, the option datatype=integer[1] can be used to produce images represented as 8-bit integer values per pixel. Note that the Maple data type integer[1] is signed allows the 8-bit values -128..127, whereas an 8-bit image requires values in the range 0 to 255. Thus, any code generating such an image must transform the values 128 to 255 into -128 to -1.
fit = truefalse
If true, scales all layers so that the intensity is between 0 and 1. Calls FitIntensity. The default is false.
The Create command creates an image.
The optional height and width parameters specify the image height and width dimensions, in pixels. If an integer, then the index ranges from one to that value. If a range of integers, then that is used for the index range.
The optional layers parameter specifies the number of layers in the image. There may be 1, 3, or 4 layers in an image. The layers parameter is equivalent to the channels option. If specified as a range, the left side of the range must be 1.
Initialization Data
The optional data parameter specifies data that is used to initialize the image. It can be a 2D or 3D Array, a Matrix, a list of numeric lists, a list of lists of numeric lists, a procedure, a list of procedures, a set of equations of the form index=value, or a table.
If data is an Array or Matrix (instances of rtables), the resulting image rtable is an Array or Matrix, respectively. The order is inherited from the input rtable.
If the input rtable has datatype=float[8], storage=rectangular and no indexing functions, the rtable becomes the image rtable (that is, no copy is made) unless the copy=true option is specified.
If data is a list of numeric lists, the number of elements in the main list determines the number of rows in the image, and the number of elements in the first sublist determines the number of columns. The result is a 2D Array, giving a single-channel (grayscale) image. Each sublist becomes a row in the image, and each value in the sublist becomes one pixel in that row. If any subsequent sublists are longer than the first, the extra values are ignored. Shorter sublists are padded with the value specified by the background option described below.
If data is a list of lists of numeric lists, the number of elements in the outer list determines the number of rows in the image, the number of elements in the first sublist determines the number of columns, and the number of elements in the first sub-sublist determines the number of layers (color channels). The treatment of mismatched subsequent sublists is as in the previous case.
If data is a procedure, a set, or a table, the size of the image is set by the height, width and layers parameters.
If data is a procedure, it is called for each location in the image, being passed either a (row,column) pair for a grayscale image, or a (row,column,layer) triple for a color image. It is expected to return the intensity value for that location (usually in the range 0..1).
If data is a set, it must contain equations of the form index=value, where index is a (row,column) pair, or a (row,column,layer) triple, and value is the intensity for that location. Unspecified entries are initialized according to the background option described below.
If data is a table, the indices in the image that correspond to entries in the table are initialized to those values. Unspecified locations in the image are initialized according to the background option described below.
If data is a list of procedures, the size of the image is set by the height and width parameters, and the number of layers corresponds to the number of procedures in the list. The i-th procedure in the list generates the intensities for layer i. Each procedure is passed a (row,column) pair for each location in the image and is expected to return the intensity value of that layer at that location.
with⁡ImageTools:
img≔Create⁡480,640
img1,1
0.
img≔Create⁡240,320,channels=1,background=white,order=Fortran_order
1.
img≔Create⁡160,160,channels=1,r,c↦evalhf⁡sin⁡c⋅r3202+0.5
img1,1,img2,2
0.501562497456870,0.506249837240855
img := Create(160,160,channels=1, proc(r,c) local z := round(evalhf(sin(r*c/320)*127)+128); if z > 127 then z -= 256 fi; z end, datatype=integer[1]);
−128,−126
See Also
convert/Image
ImageTools[FitIntensity]
Download Help Document