CLabels:Preferences


The Preferences method creates a text label on an image. This method opens a dialog like that shown below. See the Mira User's Guide for more information about labeling images.

 

Syntax

bSuccess = CLabels:Preferences()

where

     

    The [OK] and [Apply] buttons apply changes to the current script only.

    The [Save] button sets the attributes as the default for future scripts or Mira use.

    bSuccess is the returned success code. If you click [Cancel] or the attached CImageView is nilthen false is returned.

  

This method sets preferences for all labels drawn after the dialog is closed. If this method is not used, the labels use default settings. This dialog might be opened immediately after construction of the CLabels object to set preferences for all labels. The effect of changes is to alter the label attributes for all images in the CImageView. This happens even if you call the Preferences method in the middle of a loop for an intermediate image in the image set. After the script finishes, you can also update the label attributes by clicking on the Label toolbar on the image window.

Example

The following script tracks a centroid position through the image set and draws a label at the centroid coordinate on each image. The preferences method is used to set different label attributes before a label is added to each image:

V = LoadImages()

-- open and display images in a CImageView

L = CLabels:new( V )

-- create a CLabels object

bSuccess = L:Preferences() ; Assert(bSuccess)

-- set label preferences, or exit the script

C = CCentroid:new()

-- create a CCentroid object

x = 192 ; y = 390

-- starting position for centroid

for i=1,V:Count() do

-- loop over all images

 V:SetIndex( i )

-- change to the next image

 I = V:GetImage()

-- attach the current displayed image

 if ( C:Calc( I, x, y ) ) then

 

   x = C:X() ; y = C:Y()

-- get the centroid position

   s = Sprintf("Centroid:\r\n%lg,%lg",x,y)

-- label text

   L:Add( I, x, y, s )

-- draw the label on this image

 end

 

end

 

C:delete()

-- delete the object

L:delete()

-- delete the object

Related Topics

Add

CLabels class