Overview of the ImageTools:-Draw Package - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Graphics : Image Processing : ImageTools Package : Draw Subpackage : ImageTools/Draw

Overview of the ImageTools:-Draw Package

 

Calling Sequence

Description

List of ImageTools:-Draw Package Commands

Coordinate System

Primitives

Examples

Compatibility

Calling Sequence

ImageTools[Draw][command]( arguments )

command( arguments )

Description

• 

ImageTools:-Draw is a subpackage of ImageTools that provides primitives for drawing into an ImageTools:-Image. All primitives work in terms of continuous mathematical coordinates, not discrete pixels, and are rendered using anti-aliasing.

List of ImageTools:-Draw Package Commands

• 

The following is a list of the commands in the ImageTools[Draw] package.

Circle

Line

Poly

SolidRectangle

Text

TextSize

 

 

Coordinate System

• 

ImageTools:-Draw uses a different coordinate system than that of the underlying ImageTools:-Image. An Image is an H×W, H×W×3, or H×Wx4 Array of double precision (64-bit) hardware floating point values, each representing a pixel. The top-left pixel of the image has the coordinates [1,1] and the bottom-right pixel is at [H,W]. Notice that this is both upside-down compared to Cartesian coordinates (the lowest y value is at the top), and also that the order of coordinates is reversed (the coordinates are of the form [y,x]). This was done to correspond with the conventions of indexing arrays and matrices, where indexing starts at the top, and the row is specified first.

• 

The coordinate system used by ImageTools:-Draw is that of the upper-right quadrant of the Cartesian coordinate system. Furthermore, the coordinates refer to pixel boundaries, not the pixels themselves. For an image stored in an H×W Array, ImageTools:-Draw coordinates are of the form [x,y], where 0 ≤ x ≤ W and 0 ≤ y ≤ H. The bottom-left corner has coordinates [0,0] and the top-right corner [W,H].

• 

The coordinates specified in ImageTools:-Draw commands are not restricted to integer values. A point, such as the endpoint of a line, can be specified to be anywhere within the range of valid coordinates. Since all primitives drawn by ImageTools:-Draw are rendered using anti-aliasing, sub-pixel-sized changes in the positions of points are actually visible. The images below were generated at 20 pixels width and 15 pixels height, magnified by a factor of 16, and then augmented with red crosshairs to show the mathematical endpoints of the lines.

  

Line from (2.0,2.0) to (18.0,13.0), thickness=1:

  

Line from (2.5,2.5) to (17.5,12.5), thickness=1:

  

The correspondence between point coordinates [x,y] and Array indices [r,c] is given by:

  

c = x + 0.5

  

r = (H + 1) - (y + 0.5) 

Primitives

• 

After first creating an image using ImageTools:-Create, or loading an image with ImageTools:-Read, drawing operations can be performed on it using a number of primitives (functions that draw one kind of object). The first argument to each primitive is the image itself, as returned by Create or Read.

• 

Each primitive is a member of the ImageTools:-Draw package, and can be referenced by prefixing the primitive name with the package name (e.g., ImageTools:-Draw:-Poly), or using the bare primitive name in a context in which ImageTools:-Draw is in scope: after a call to with(ImageTools:-Draw), within a procedure having a uses ImageTools:-Draw clause, or within a use ImageTools:-Draw in ... end statement.

• 

In addition to the drawing primitives any other command from the ImageTools package can be applied to the image at any time, so one can combine drawing operations with other image manipulation techniques.

Examples

withImageTools:

withImageTools:-Draw:

imgCreate240,240,channels=3,background=white:

Circleimg,120,120,24064,color=0.5,thickness=3

Polyimg,60,60,60,180,180,180,180,60,60,60,color=0,fill_color=0.9,1,0.8,fill_pattern=sphere

Textimg,121,131,Draw,color=0.6,0.2,0.2,font=18,font_size=30:

Textimg,120,130,Draw,color=0.4,0.1,0.1,font=18,font_size=30:

exprx1202+y1202=2406422:

rsolveexpr,y

r120+x2+240x6656,120x2+240x6656

(6.1)

forx1from32.by11.to208.doSolidCircleimg,x1,r1'x'=x1|r1'x'=x1,5,color=black;SolidCircleimg,x1,r2'x'=x1|r2'x'=x1,5,color=redend do

Embedimg

Compatibility

• 

The ImageTools[Draw] package was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

ImageTools

ImageTools:-Draw:-Circle

ImageTools:-Draw:-Line

ImageTools:-Draw:-Poly

ImageTools:-Draw:-SolidRectangle

ImageTools:-Draw:-Text

ImageTools:-Draw:-TextSize