ilt SciMax Toolbox imagpart

SciMax Toolbox >> image

image

Maxima Graphic object

Calling Sequence

image (im,x0,y0,width,height)

Description

Renders images in 2D.

2D

image (im,x0,y0,width,height) plots image im in the rectangular region from vertex (x0,y0) to (x0+width,y0+height) on the real plane. Argument im must be a matrix of real numbers, a matrix of vectors of length three or a picture object.

If im is a matrix of real numbers or a levels picture object, pixel values are interpreted according to graphic option palette, which is a vector of length three with components ranging from -36 to +36; each value is an index for a formula mapping the levels onto red, green and blue colors, respectively:

0: 0               1: 0.5           2: 1
3: x               4: x^2           5: x^3
6: x^4             7: sqrt(x)       8: sqrt(sqrt(x))
9: sin(90x)       10: cos(90x)     11: |x-0.5|
12: (2x-1)^2       13: sin(180x)    14: |cos(180x)|
15: sin(360x)      16: cos(360x)    17: |sin(360x)|
18: |cos(360x)|    19: |sin(720x)|  20: |cos(720x)|
21: 3x             22: 3x-1         23: 3x-2
24: |3x-1|         25: |3x-2|       26: (3x-1)/2
27: (3x-2)/2       28: |(3x-1)/2|   29: |(3x-2)/2|
30: x/0.32-0.78125                  31: 2*x-0.84
32: 4x;1;-2x+1.84;x/0.08-11.5
33: |2*x - 0.5|    34: 2*x          35: 2*x - 0.5
36: 2*x - 1

negative numbers mean negative colour component.

palette = gray and palette = color are short cuts for palette = [3,3,3] and palette = [7,5,15], respectively.

If im is a matrix of vectors of length three or an rgb picture object, they are interpreted as red, green and blue color components.

Examples:

If im is a matrix of real numbers, pixel values are interpreted according to graphic option palette.

(%i1) load(draw)$
(%i2) im: apply(
           'matrix,
            makelist(makelist(random(200),i,1,30),i,1,30))$
(%i3) /* palette = color, default */
      draw2d(image(im,0,0,30,30))$
(%i4) draw2d(palette = gray, image(im,0,0,30,30))$
(%i5) draw2d(palette = [15,20,-4],
             colorbox=false,
             image(im,0,0,30,30))$

See also .

If im is a matrix of vectors of length three, they are interpreted as red, green and blue color components.

(%i1) load(draw)$
(%i2) im: apply(
            'matrix,
             makelist(
               makelist([random(300),
                         random(300),
                         random(300)],i,1,30),i,1,30))$
(%i3) draw2d(image(im,0,0,30,30))$

Package draw automatically loads package picture. In this example, a level picture object is built by hand and then rendered.

(%i1) load(draw)$
(%i2) im: make_level_picture([45,87,2,134,204,16],3,2);
(%o2)       picture(level, 3, 2, {Array:  #(45 87 2 134 204 16)})
(%i3) /* default color palette */
      draw2d(image(im,0,0,30,30))$
(%i4) /* gray palette */
      draw2d(palette = gray,
             image(im,0,0,30,30))$

An xpm file is read and then rendered.

(%i1) load(draw)$
(%i2) im: read_xpm("myfile.xpm")$
(%i3) draw2d(image(im,0,0,10,7))$

See also , and .

URL http://www.telefonica.net/web2/biomates/maxima/gpdraw/image contains more elaborated examples.

ilt SciMax Toolbox imagpart