Create - Maple Help

ImageTools

 Create
 create an image

 Calling Sequence Create( height, width, layers, data, opts)

Parameters

 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

Options

 • 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, 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, Fortran_order
 Specifies how the data is stored in memory. See Fortran_order. Unlike rtable, the default is C_order.
 • fit = truefalse
 If true, scales all layers so that the intensity is between 0 and 1.  Calls FitIntensity. The default is false.

Description

 • 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 $\mathrm{index}=\mathrm{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 $\mathrm{index}=\mathrm{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.

Examples

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$
 > $\mathrm{img}≔\mathrm{Create}\left(480,640\right)$
 ${\mathrm{img}}{≔}\begin{array}{c}\left[\begin{array}{ccccccccccc}{0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {0.}& {\dots }\\ {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {}\end{array}\right]\\ \hfill {\text{480 × 640 Array}}\end{array}$ (1)
 > $\mathrm{img}\left[1,1\right]$
 ${0.}$ (2)
 > $\mathrm{img}≔\mathrm{Create}\left(240,320,\mathrm{channels}=1,\mathrm{background}=\mathrm{white},\mathrm{order}=\mathrm{Fortran_order}\right)$
 ${\mathrm{img}}{≔}\begin{array}{c}\left[\begin{array}{ccccccccccc}{1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {}\end{array}\right]\\ \hfill {\text{240 × 320 Array}}\end{array}$ (3)
 > $\mathrm{img}\left[1,1\right]$
 ${1.}$ (4)
 > $\mathrm{img}≔\mathrm{Create}\left(160,160,\mathrm{channels}=1,\left(r,c\right)↦\mathrm{evalhf}\left(\mathrm{sin}\left(\frac{c\cdot r}{320}\right)\right)\right)$
 ${\mathrm{img}}{≔}\begin{array}{c}\left[\begin{array}{ccccccccccc}{0.00312499491373946}& {0.00624995930997531}& {0.00937486267150194}& {0.0124996744817098}& {0.0156243642248834}& {0.0187489013864992}& {0.0218732554535240}& {0.0249973959147123}& {0.0281212922609048}& {0.0312449139853261}& {\dots }\\ {0.00624995930997531}& {0.0124996744817098}& {0.0187489013864992}& {0.0249973959147123}& {0.0312449139853261}& {0.0374912115554603}& {0.0437360446299103}& {0.0499791692706783}& {0.0562203416065019}& {0.0624593178423802}& {\dots }\\ {0.00937486267150194}& {0.0187489013864992}& {0.0281212922609048}& {0.0374912115554603}& {0.0468578357481342}& {0.0562203416065019}& {0.0655779062600986}& {0.0749297072727424}& {0.0842749227148172}& {0.0936127312355129}& {\dots }\\ {0.0124996744817098}& {0.0249973959147123}& {0.0374912115554603}& {0.0499791692706783}& {0.0624593178423802}& {0.0749297072727424}& {0.0873883890887872}& {0.0998334166468282}& {0.112262845436629}& {0.124674733385228}& {\dots }\\ {0.0156243642248834}& {0.0312449139853261}& {0.0468578357481342}& {0.0624593178423802}& {0.0780455513899673}& {0.0936127312355129}& {0.109157056875322}& {0.124674733385228}& {0.140161972347064}& {0.155614992773556}& {\dots }\\ {0.0187489013864992}& {0.0374912115554603}& {0.0562203416065019}& {0.0749297072727424}& {0.0936127312355129}& {0.112262845436629}& {0.130873493387404}& {0.149438132473599}& {0.167950236255494}& {0.186403296762270}& {\dots }\\ {0.0218732554535240}& {0.0437360446299103}& {0.0655779062600986}& {0.0873883890887872}& {0.109157056875322}& {0.130873493387404}& {0.152527307385215}& {0.174108137593596}& {0.195605657659879}& {0.217009581095010}& {\dots }\\ {0.0249973959147123}& {0.0499791692706783}& {0.0749297072727424}& {0.0998334166468282}& {0.124674733385228}& {0.149438132473599}& {0.174108137593596}& {0.198669330795061}& {0.223106362131745}& {0.247403959254523}& {\dots }\\ {0.0281212922609048}& {0.0562203416065019}& {0.0842749227148172}& {0.112262845436629}& {0.140161972347064}& {0.167950236255494}& {0.195605657659879}& {0.223106362131745}& {0.250430597618066}& {0.277556751646336}& {\dots }\\ {0.0312449139853261}& {0.0624593178423802}& {0.0936127312355129}& {0.124674733385228}& {0.155614992773556}& {0.186403296762270}& {0.217009581095010}& {0.247403959254523}& {0.277556751646336}& {0.307438514580381}& {\dots }\\ {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {}\end{array}\right]\\ \hfill {\text{160 × 160 Array}}\end{array}$ (5)
 > $\mathrm{img}\left[1,1\right],\mathrm{img}\left[2,2\right]$
 ${0.00312499491373946}{,}{0.0124996744817098}$ (6)