CLabels:Add
The Add method creates a text label on an image like that shown below. The script that create this is given in the Examples section.
|
|
bSuccess = CLabels:Add( CImage, x, y, str ) |
This method draws a label on a displayed image, a CImage, attached to a CImageView object. The label consists of a marker and a text string. The marker and text string are both optional. If the text string spans multiple lines, the string should be formatted using \r\n escape characters between lines (see example below). The Preferences method can also be used to choose the label attributes before labels are added. See the Mira User's Guide for further information about adding labels to images.
The label attributes and the label text can be changed after the label is created by using the buttons on the Label toolbar on the image window. See the Mira User's Guide for further information.
This example produced the result shown above. The following script fragment opens multiple images into a window, then tracks a centroid position through the image set. A label containing the centroid coordinates is drawn at each position on each image. After each image, the centroid coordinates are used as starting coordinates in the Calc method for computing the centroid for the next image in the loop:
|
-- load and display images in a loop |
|
-- create a CLabels object |
|
-- create a CCentroid object |
|
-- starting position for centroid |
|
-- loop over all images |
|
-- change to the next image |
|
-- attach the current displayed image |
|
|
|
-- get the centroid position |
|
-- label text |
|
-- draw the label on this image |
|
|
|
|
|
-- delete the object |
|
-- delete the object |