Image Drawing Functions
[Functions]


Functions

image CopyImg (image Img)
 Creates a copy of an image.
list DrawImg (scalar X, scalar Y, scalar Z, string Filename)
 Loads an image file and displays it.
list DrawImg (multivector P, string Filename)
 Loads an image file and displays it.
void EnableImgTransparency (counter DoEnable)
 Enables or disables transparency in images.
list GetImgCoords (image P)
 Get world (visualization) coordinates of an image.
matrix Img2Matrix (image P, scalar channel)
 Convert an image to a matrix representation.
void InsertImg (image imgTarget, image imgSource, counter iX, counter iY, counter iTC, counter iSC)
 Insert an image into another one.
image Matrix2Img (list M, list C)
 Compute color image out of up to three matrices.
image Matrix2Img (matrix M)
 Convert matrix to greyscale image.
image ReadImg (string Filename)
 Loads an image file.
void ReshapeImg (image Img, counter iWidth, counter iHeight, color colClear)
 Resizes the image canvas.
void ResizeImg (image Img, counter iWidth, counter iHeight)
 Resize an image.
void SetImgAlign (scalar X, scalar Y)
 Sets the alignment of an image relative to the point where it should be drawn.
void SetImgPos (multivector P)
 Set origin position for images.
void SetImgPos (scalar X, scalar Y, scalar Z)
 Set origin position for images.
void SetImgScale (scalar Scale)
 Sets the scale with which images are drawn.
void SetImgTransparentColor (color Col)
 Sets the transparent color for images.
list Size (image P)
 Returns the dimension of an image.

Detailed Description

These functions allow you to load and draw bitmaps.

Attention:
Note that there is no explicit function to extract an area of an image. This can be done with the bracket operator (). For example, if I is an image variable, you can extract the part of the image starting at coordinates x and y with width w and height h via I(x, y, w, h).

Function Documentation

image CopyImg image  Img  ) 
 

Creates a copy of an image.

Parameters:
Img The image to be copied.
Returns:
A copy of Img.
Since:
v2.2
If you use the operator <tt>= to assign an image to a new variable, the actual image is not copied. Only a reference to it is assigned. To create an actual copy, you need to use this function.

list DrawImg scalar  X,
scalar  Y,
scalar  Z,
string  Filename
 

Loads an image file and displays it.

Parameters:
X The x-coordinate of the draw position.
Y The y-coordinate of the draw position.
Z The z-coordinate of the draw position.
Filename The filename of the image file.
Returns:
A list containing the actual extend of the displayed image in current coordinates. This list contains six entries. The first three give the x, y and z coordinates of the bottom left corner of the image, and the last three give the x, y and z coordinates of the top right corner of the bitmap. This can, for example, be used to draw two images next to each other.
Since:
v1.4
Attention:
Currently this function can only read bitmap files with 24bit color resolution. More image file types will be implemented in the future.

list DrawImg multivector  P,
string  Filename
 

Loads an image file and displays it.

Parameters:
P A vector giving the position of where to draw the image.
Filename The filename of the image file.
Returns:
A list containing the actual extend of the displayed image in current coordinates. This list contains six entries. The first three give the x, y and z coordinates of the bottom left corner of the image, and the last three give the x, y and z coordinates of the top right corner of the bitmap. This can, for example, be used to draw two images next to each other.
Since:
v1.4
Attention:
Currently this function can only read bitmap files with 24bit color resolution. More image file types will be implemented in the future.

void EnableImgTransparency counter  DoEnable  ) 
 

Enables or disables transparency in images.

Parameters:
DoEnable If this boolean flag is zero then transparency is disabled, otherwise enabled.
Since:
v1.4
If transparency is enabled, those pixel in an image that have the same color as the transparent color, which is set with the function SetImgTransparentColor(), are made transparent. Image pixels are only made transparent when an image is loaded, not every time it is displayed.

list GetImgCoords image  P  ) 
 

Get world (visualization) coordinates of an image.

Parameters:
P An Image.
Returns:
A list containing the actual extend of the displayed image in current coordinates. This list contains six entries. The resultant values reflect size, scale, origin and align of the image. See e.g. funtion DrawImage for more information.
Since:
v2.0

matrix Img2Matrix image  P,
scalar  channel
 

Convert an image to a matrix representation.

Parameters:
P An Image.
channel The colorchannel (optional) red (1), green (2) or blue (3).
Returns:
A matrix M with values $ 0\le g\le 1$ .
Since:
v2.0
If no channel is specified the grey channel will be choosen (default).

void InsertImg image  imgTarget,
image  imgSource,
counter  iX,
counter  iY,
counter  iTC,
counter  iSC
 

Insert an image into another one.

Parameters:
imgTarget The target image.
imgSource The image to be inserted.
iX The x-position in the target image where the bottom left corner of the source image is to be inserted.
iY The y-position in the target image where the bottom left corner of the source image is to be inserted.
iTC (optional) The color channel of the target image to copy to.
iSC (optional) The color channel of the source image to use.
Returns:
Nothing.
Since:
v2.2
This function inserts an image into another one. If color channels are given, then only the respective source channel is copied into the target channel. A channel is denoted by an integer, 1:red, 2:green, 3:blue, 4:alpha. Copying into the alpha channel makes the target image transparent at the corresponding pixel. See also the example script ExampleScripts/Images/ImageEx9.clu.

image Matrix2Img list  M,
list  C
 

Compute color image out of up to three matrices.

Parameters:
M A list of maximum three matrices with values out of $ [0\,\ldots\,1]$ .
C A list of numbers representing the corresponding color channels.
Returns:
An image.
Since:
v2.0
Values that exceed the above quoted intervall will be clamped to that range. The following code generates a little smooth green image:
    
    ? C = Matrix( [0,1,2,3,4,5,6,7,8,9] );
    C = C * ~C / 81; // Get a square matrix
    L1 = C(1,1,5,5); // extract three submatrices
    L2 = C(4,4,5,5);
    L3 = C(6,6,5,5);
    SetImgScale( 50 );
    :Matrix2Img( [ L1,L2,L3 ], [1,3,2] );
    // :Matrix2Img( [ L1,L2 ], [1,3] );

Toggle the comments of the last two lines and see what happens.

image Matrix2Img matrix  M  ) 
 

Convert matrix to greyscale image.

Parameters:
M A Matrix with values out of $ [0\,\ldots\,1]$ .
Returns:
A greyscale image.
Since:
v2.0
Values in matrix M exceeding the above quoted intervall will be clamped to that range.

image ReadImg string  Filename  ) 
 

Loads an image file.

Parameters:
Filename The filename of the image file.
Returns:
An image.
Since:
v2.0
Attention:
Currently this function can only read bitmap files with 24bit color resolution. More image file types will be implemented in the future.

void ReshapeImg image  Img,
counter  iWidth,
counter  iHeight,
color  colClear
 

Resizes the image canvas.

Parameters:
Img The image to be reshaped.
iWidth The new canvas width.
iHeight The new canvas height.
colClear (optional) The clear color for added canvas areas. Default is black.
Returns:
Nothing.
Since:
v2.2
This function resizes the canvas of an image relative to the image's center. If the canvas is enlarged, then empty parts of the canvas are set to the optionally given value of colClear. See also the example script ExampleScripts/Images/ImageEx8.clu.

void ResizeImg image  Img,
counter  iWidth,
counter  iHeight
 

Resize an image.

Parameters:
Img The image that is to be resized.
iWidth New image width.
iHeight New image height.
Returns:
Nothing.
Since:
v2.2
This function resizes an image to the given dimensions. See also the example script ExampleScripts/Images/ImageEx8.clu.

void SetImgAlign scalar  X,
scalar  Y
 

Sets the alignment of an image relative to the point where it should be drawn.

Parameters:
X The alignment along the x-direction.
Y The alignment along the y-direction.
Since:
v1.4
If X and Y are both zero (the default), then a image is drawn with its bottom left corner at the position given in the DrawImg() function. If X = 1 and Y = 0, then the image is aligned with its bottom right corner. If X = 0 and Y = 1, then the image is aligned with its top left corner. The parameters X and Y can also take on negative values. If you want to center an image on the point given in DrawImg(), set X = 0.5 and Y = 0.5.

void SetImgPos multivector  P  ) 
 

Set origin position for images.

Parameters:
P A vector in Euclidean, projective or conformal space that gives the origin.
Returns:
nothing.
Since:
v2.0

void SetImgPos scalar  X,
scalar  Y,
scalar  Z
 

Set origin position for images.

Parameters:
X The x-coordinate of the origin.
Y The y-coordinate of the origin.
Z The z-coordinate of the origin.
Returns:
nothing.
Since:
v2.0

void SetImgScale scalar  Scale  ) 
 

Sets the scale with which images are drawn.

Parameters:
Scale The scale.
Since:
v1.4
If the scale is larger than one, the image is enlarged. If the scale is smaller than one, the image is drawn smaller than normal. This scale is valid for all images drawn after the execution of this function.

void SetImgTransparentColor color  Col  ) 
 

Sets the transparent color for images.

Parameters:
Col The color that is to be regarded as transparent in images.
Since:
v1.4
This transparent color only takes effect, when transparency in images is enabled. Image pixels are only made transparent when an image is loaded, not every time it is displayed.

list Size image  P  ) 
 

Returns the dimension of an image.

Parameters:
P An image.
Returns:
A list containing the number of rows and columns.
Since:
v2.0
If Size is applied to an image the result will be a list of two scalars. The first represents the number of rows while the second represents the number of columns. For further information or an example see the Size function for matrices. Size applied to a scalar val is equivalent to $( \mathtt{val}\; != 0)$ .