Nächste: , Vorige: , Nach oben: draw   [Inhalt][Index]

42.3 Functions and Variables for pictures

Function: get_pixel (pic, x, y)

Returns pixel from picture. Coordinates x and y range from 0 to width-1 and height-1, respectively.

Function: make_level_picture (data)
Function: make_level_picture (data, width, height)

Returns a levels picture object. make_level_picture(data) builds the picture object from matrix data. make_level_picture(data, width, height) builds the object from a list of numbers; in this case, both the width and the height must be given.

The returned picture object contains the following four parts:

  1. symbol level
  2. image width
  3. image height
  4. an integer array with pixel data ranging from 0 to 255. Argument data must contain only numbers ranged from 0 to 255; negative numbers are substituted by 0, and those which are greater than 255 are set to 255.

Example:

Level picture from matrix.

(%i1) load("draw")$
(%i2) make_level_picture(matrix([3,2,5],[7,-9,3000]));
(%o2)         picture(level, 3, 2, {Array:  #(3 2 5 7 0 255)})

Level picture from numeric list.

(%i1) load("draw")$
(%i2) make_level_picture([-2,0,54,%pi],2,2);
(%o2)            picture(level, 2, 2, {Array:  #(0 0 54 3)})
Function: make_rgb_picture (redlevel, greenlevel, bluelevel)

Returns an rgb-coloured picture object. All three arguments must be levels picture; with red, green and blue levels.

The returned picture object contains the following four parts:

  1. symbol rgb
  2. image width
  3. image height
  4. an integer array of length 3*width*height with pixel data ranging from 0 to 255. Each pixel is represented by three consecutive numbers (red, green, blue).

Example:

(%i1) load("draw")$
(%i2) red: make_level_picture(matrix([3,2],[7,260]));
(%o2)           picture(level, 2, 2, {Array:  #(3 2 7 255)})
(%i3) green: make_level_picture(matrix([54,23],[73,-9]));
(%o3)           picture(level, 2, 2, {Array:  #(54 23 73 0)})
(%i4) blue: make_level_picture(matrix([123,82],[45,32.5698]));
(%o4)          picture(level, 2, 2, {Array:  #(123 82 45 33)})
(%i5) make_rgb_picture(red,green,blue);
(%o5) picture(rgb, 2, 2, 
              {Array:  #(3 54 123 2 23 82 7 73 45 255 0 33)})
Function: negative_picture (pic)

Returns the negative of a (level or rgb) picture.

Function: picture_equalp (x,y)

Returns true in case of equal pictures, and false otherwise.

Function: picturep (x)

Returns true if the argument is a well formed image, and false otherwise.

Function: read_xpm (xpm_file)

Reads a file in xpm and returns a picture object.

Function: rgb2level (pic)

Transforms an rgb picture into a level one by averaging the red, green and blue channels.

Function: take_channel (im,color)

If argument color is red, green or blue, function take_channel returns the corresponding color channel of picture im.

Example:

(%i1) load("draw")$
(%i2) red: make_level_picture(matrix([3,2],[7,260]));
(%o2)           picture(level, 2, 2, {Array:  #(3 2 7 255)})
(%i3) green: make_level_picture(matrix([54,23],[73,-9]));
(%o3)           picture(level, 2, 2, {Array:  #(54 23 73 0)})
(%i4) blue: make_level_picture(matrix([123,82],[45,32.5698]));
(%o4)          picture(level, 2, 2, {Array:  #(123 82 45 33)})
(%i5) make_rgb_picture(red,green,blue);
(%o5) picture(rgb, 2, 2, 
              {Array:  #(3 54 123 2 23 82 7 73 45 255 0 33)})
(%i6) take_channel(%,'green);  /* simple quote!!! */
(%o6)           picture(level, 2, 2, {Array:  #(54 23 73 0)})

Nächste: , Vorige: , Nach oben: draw   [Inhalt][Index]