Working with macros

Recording a macro

Recording a macro

Running a macro

Using the "Macro Manager" tool window

Defining a button

Editing a macro

Adding a dialog box showing a message

Creating an interactive macro

Customizing function parameters

Adding or deleting functions

Using a macro batch process

Running a macro automatically for several images

See also

Overview - Macros

Tool Window - Macro Manager

Overview - Batch Process for macros

Recording a macro

For example: You want to take a snapshot using a specific resolution and exposure time. At the same time you want to be certain that in every case the scale bar will appear in the image.

Making preparations for a macro recording

In your mind, go once through the functions that you want to use during the macro recording, and set up the user interface accordingly. Take special care that all of the toolbars and tool windows you want to use are on display.

In this case the scale bar is to appear in the image. To be able to record this command correctly, check whether the scale bar is on display, or not. Should the scale bar be visible, use the View > Scale Bar command to hide it.

Set the acquisition conditions you want, and save them in a parameter set.

Use the View > Tool Windows > Camera Control command to show the Camera Control tool window.

Select the Exposure > Manual option, and enter the exposure time.

Select the resolution you want from the Resolution > Snap list.

Click the Save Camera Settings button located on the Camera Control tool window's toolbar, and save a parameter set containing the camera settings.

You can, of course, also edit a macro subsequently, should you not have been able to record it as you wanted to.

Use the View > Tool Windows > Macro Manager command to make the Macro Manager tool window appear.

Setting up a new macro

Click the Create Macro bb_new_macro button in the tool window's toolbar.

The New Macro dialog box will open.

Enter a name for the macro in the Name field. Select a short name with a clear meaning, that accurately describes the macro's function.

You will later find this macro under that name in the Macro Manager tool window's list of functions.

In the Screen Tip description field, enter a short description of the macro's functionality.

You can define a button for the macro at a later date. The description will then be displayed when you move your mouse pointer over this button.

Close the New Macro dialog box with OK.

The Macro Manager tool window will then be in the recording mode. In this mode only the buttons for interrupting and for ending, the macro recording, will be available.

The name of the active macro will be displayed beneath the toolbar.

The list of functions will still be empty.

Commands you use and the actions you carry out in your software from now on, will be recorded. Please note that not all commands can be recorded.

Recording functions

In the toolbar of the Camera Control tool window, click the Save Camera Settings button. Select the parameter set which contains the camera settings you want. In the Load Camera Settings dialog box, click the Load button.

In the Macro Manager tool window's list of functions, the [Load Camera Settings] function will then appear as the first function.

Use the Acquire > Snapshot command to acquire a snapshot.

In the list of functions, the next function [Snapshot] will then appear.

Use the View > Scale Bar command to have a scale bar displayed in the image.

In the list of functions, the next function [Scale Bar - on] appears.

Finishing the macro recording

In the tool window's toolbar, click the Stop Macro Running / Recording bb_stopanimation button.

The Macro Manager tool window will end the recording mode.

The macro that has been recorded will then be automatically saved. From now on you can select it in the Macro Manager tool window's list of macros.

Now you can run the macro.

Running a macro

Click the Run Macro bb_playanimation button in the tool window's toolbar.

Your software will then carry out all of the functions that have been recorded one after the other. In this case you carry out three commands with one mouse click.

There are a number of ways in which you can run macros. You will find an overview of the various possibilities here.

back to top

Running a macro: Using the "Macro Manager" tool window

There are a number of ways in which you can run macros. You will find an overview of all of the possibilities here.

Note: Numerous macros can only be run when certain requirements have been fulfilled. A macro that combines different image processing functions for example, can only run when an image has been loaded. If you try to run this macro when no image has been loaded, you will receive an error message.

Running a macro from the "Macro Manager" tool window

1.Activate the macro in the Macro Manager tool window.

Select the macro for this in the macro list located immediately beneath the tool window's toolbar.

2.In the tool window's toolbar, click the Run Macro bb_playanimation button to run the macro.

back to top

Running a macro: Defining a button

Use the Tools > Customization > Start Customize Mode... command.

Select the Toolbars tab in the Customize dialog box.

Click the New... button.

Enter a name for the new toolbar in the Toolbar Name dialog box. Confirm your settings with OK.

toolbar_new The new toolbar will be shown in the upper left screen area. Since it does not yet contain any buttons, it can easily be overlooked. Look out for a toolbar that's empty, like the one shown above.

Go to the Commands tab.

Select the User Macros command group in the Categories list.

In the Commands list you will then see all of the macros that you have up till now defined. Additionally, the macros that have been published and thus made available for all users, will also be listed.

Select the macro you want in the Commands list and drag it to your personal toolbar.

Should you wish to, you can change the appearance of the buttons. To do so, use the Button Appearance command.

Click the Close button to finalize the new toolbar configuration.

Move your mouse pointer over the button.

Your software will make the description that you defined when the macro was created, appear.

The newly set up software configuration with the macro toolbar will be automatically loaded the next time you start your software.

You can now run the macro any time you want to by clicking this button.

back to top

Editing a macro: Adding a dialog box showing a message

For example: With some images, a Sharpen filter yields better results when you smooth the image before using it. For this reason you want to define a macro that will carry out both of these image processing functions, NxN and Sharpen, one after the other.

You want to define a dialog box with a corresponding message, so that the user will know that he has to load an image before he runs the macro.

Recording macro "My Sharpen"

Load an image.

Insert a new "My Sharpen Filter" macro.

Start the macro recording.

Use the Process > Smoothing Filters > NxN... command.

Set the required parameter, then close the dialog box with OK.

Use the Process > Sharpen Filters > Sharpen... command.

Set the required parameter, then close the dialog box with OK.

Finish the macro recording.

In the Macro Manager tool window's list of functions the following functions will then be listed:

[NxN]

[Sharpen]

Defining a dialog box showing as user message

Select the first function in the Macro Manager tool window.

The functions you have selected will be highlighted in color in the tool window.

Move your mouse pointer onto the Macro Manager tool window's list of functions. Click the right mouse button to open a context menu.

Use the Insert special command > User Message / Delay command from the context menu.

The User Message / Delay dialog box will open. In it you can write a message that will be displayed in a dialog box when the macro is run.

Enter the dialog box's title in the Title field. You can do this using the name of the macro.

Enter the text that is to be displayed in the dialog box, in the Message field. In this case, enter something like: "Please load an image for the 'Smoothing Filter and Sharpen Filter' image processing operation."

Note: When you enter this message, please take care that you use suitable word-wraps. The message will later appear in the dialog box exactly as you enter it here.

Clear the Start delay check box.

Close the dialog box with OK.

In the Macro Manager tool window's list of functions, the [User Message] function will then appear as the first function.

Running a macro

In the tool window's toolbar, click the Run Macro bb_playanimation button to run the macro.

Your software will then display a dialog box containing the information you have entered. As long as this dialog box is open, your software's commands will still be available. That means that the user then still has enough time to load an appropriate image.

Click the Continue button to close the dialog box with the message.

The macro will then first apply the smoothing filter to the current image. This process will be carried out using the settings that were used when the macro was recorded.

The macro subsequently uses a sharpen filter with the settings that were recorded.

back to top

Editing a macro: Creating an interactive macro

By default, a function uses fixed parameters within a macro. The corresponding dialog box will, in this case, not be opened when the macro is being run.

It is, however, possible for you to specify that the dialog box will be opened while the macro is being run.

For example: You want to define a macro with which you can load an image of your choice. This image is then to be subsequently rotated through 90°.

Recording the macro "RotateImage"

Start the macro recording.

Use the File > Open > Image... command.

In the Open Image dialog box, select an image file, then close the dialog box.

To do so, use the Image > Geometry > Rotate 90° command.

Finish the macro recording.

In the Macro Manager tool window's list of functions the following functions will then be listed:

[Open Image]

[Rotate 90°]

In the Macro Manager tool window's list of functions, to the left of the [Open Image] function, this icon Icon_RunSilently will appear. This means that all of the settings in the Open Image dialog box have been saved in the macro. When you run this macro, your software will always load exactly that image that you loaded while making the macro recording.

Changing the execution mode

Click in the list of functions once on the icon Icon_RunSilently located to the left of the [Open Image] function to change the execution mode for this function.

Then the icon will look like this Icon_RunInteractively. Which means you've now changed the function's execution mode. Now, when the macro is run, the Open Image dialog box will open, enabling the user to select an image of his choice. This image will then be subsequently rotated through 90°.

back to top

Editing a macro: Customizing function parameters

You can change the function parameters in an existing macro at any time.

For example: You have defined a dialog box which contains a message, in a macro. You want to add the annotation "IMPORTANT!" to this message.

Activate the macro you want to edit, in the Macro Manager tool window.

If your macro contains a dialog box with a message, you will find the function [Message] in the Macro Manager tool window's list of functions.

If you haven't yet defined a macro that contains a message, you'll find step-by-step instructions on how to do so here.

Double click in the list of functions once on the icon Icon_Settings located to the right of the [Message] function.

The User Message / Delay dialog box will open.

Supplement the required text in the Message field.

Close the dialog box with OK.

When you now run the macro you'll see the altered text in the dialog box.

back to top

Editing a macro: Adding or deleting functions

Adding a function

Example 1: The "Sobel" macro contains the two functions [Snapshot] and [Sobel]. This macro first acquires an individual image, then subsequently uses the Process > Edge Detection Filters > Sobel... image processing operation, on it.

On the basis of this macro, you want to define another macro that first converts the image that has been acquired, into an 8-bit gray-value image.

Acquire or load a 16-bit gray-value image.

Activate the macro you want to edit, in the Macro Manager tool window. To do this, select the required macro in the list located beneath the tool window's toolbar.

In the tool window's toolbar, click the Macro Management bb_manage_macro button to open a menu with commands for the administration of macros.

Use the Duplicate Macro... command.

The Duplicate Macro dialog box will open.

Enter a name and a description for the macro.

Close the Duplicate Macro dialog box with OK.

The new macro will then have been automatically activated in the Macro Manager tool window.

In the Macro Manager tool window, select the function behind which you want to insert a new function. In this case it's the [Snapshot] function.

The functions you have selected will be highlighted in color in the tool window.

Move your mouse pointer onto the Macro Manager tool window's list of functions. Click the right mouse button to open a context menu.

Use the Recording > Insert after command from the context menu.

The Macro Manager tool window will then be in the recording mode. In this mode only the buttons for interrupting and for ending, the macro recording, will be available.

Use the Image > Mode > 8 Bit / Channel command to convert the active image into an 8-bit gray-value image.

In the list of functions, the function [8 Bit / Channel] will then appear after the function [Snapshot].

In the tool window's toolbar, click the Stop Macro Running / Recording bb_stopanimation button.

The Macro Manager tool window will end the recording mode.

Example 2: The "My Sharpen" macro combines a smoothing filter with a sharpen filter. It contains the two functions [NxN] and [Sharpen]. This macro premises that an image has already been acquired or loaded.  

You want to change the macro in such a way that an image will be automatically acquired before the two filters are applied.

Activate the macro you want to edit, in the Macro Manager tool window.

Click the Record Macro bb_record_macro button in the tool window's toolbar.

The Macro Manager tool window will then be in the recording mode. In this mode only the buttons for interrupting and for ending, the macro recording, will be available.

Use the Acquire > Snapshot command to acquire a snapshot.

In the list of functions, the function [Snapshot] will then appear. This function will be appended to the end of the list of functions.

In the tool window's toolbar, click the Stop Macro Running / Recording bb_stopanimation button.

The Macro Manager tool window will end the recording mode.

Select the [Snapshot] function in the Macro Manager tool window.

Move your mouse pointer onto the Macro Manager tool window's list of functions. Click the right mouse button to open a context menu.

Use the Move step to top command from the context menu.

The function [Snapshot] will then stand as the first in the list of functions. When you now run the macro, first a snapshot will be acquired, then the image processing functions will be applied to this image.

Deleting a function

For example: While you were recording a macro, you selected an image in the document group. For this reason, the macro contains the function [Activate document]. Now you want to delete this function from the macro.

Activate the macro you want to edit, in the Macro Manager tool window.

Select the function you want to delete, in the Macro Management tool window. In this case it's the [Activate document] function.

The functions you have selected will be highlighted in color in the tool window.

Move your mouse pointer onto the Macro Manager tool window's list of functions. Click the right mouse button to open a context menu.

Use the Delete step command from the context menu.

The deleted function now no longer belongs to the macro, and will disappear from the Macro Manager tool window's list of functions.

back to top

Using a macro batch process: Running a macro automatically for several images

Example: You want to apply one color table to several gray-value images at the same time.

Making preparations for a macro recording

Define the color table you want to use. You will find a step-by-step instruction for doing this here.

Save all the gray-value images you want to color in a specific directory.

Load one of the images that you want to color.

Recording the macro "Color image"

Create a new "Color image" macro.

Start the macro recording.

Use the Image > Pseudo Color... command. Click the Load Color Table button in the dialog box's toolbar. Select the color table you want and close all open dialog boxes.

Finish the macro recording.

Now, the Macro Manager tool window's list of function will contain the [Pseudo Color] function.

Activating the batch mode for the "Color image" macro

Click the Toggle Batch Mode bb_macrobatch button in the tool window's toolbar.

The button appears clicked, thereby showing you that the batch mode is active. You can recognize this status by the button's background color bb_MacroBatch_on.

Defining the "Color image" batch process

Click the Run Macro Batch bb_playanimation button in the tool window's toolbar.

The Define Macro Batch dialog box opens. This dialog box works similarly to a wizard. It guides you step-by-step through the definition of a batch process.

Step 1: Defining the input data

oTo start with, specify which images are to be evaluated.

oSince you have saved the images in a directory, choose the Documents in directory entry in the Input list.

oClick the Browse... button, then browse to the directory containing the images.

oThe chosen images will be displayed in the Define Macro Batch dialog box.

oClick the Next > button.

Step 2: Defining the target location

oIn the next step, you define where the resulting images are to be saved.

oSelect the File System entry in the Destination list, if the resulting images are to be saved at all.

oClick the Browse button, then select an empty directory as the target location.

oThe resulting images will then be saved in the directory specified, after the evaluation has been made.

oClick the Next > button.

oThe wizard's last dialog box shows you all of the settings you have made for the current batch process.

Step 3: Checking the settings for the batch process.

oCheck the settings.

oIf you want to correct a setting, click the underlined terms. For example, click the Output definition term if you want to change the storage location for the resulting images again.

oShould you want to change another setting, your software will jump back to the wizard's corresponding dialog box.

Running the "Color image" batch process

Click the Start button to start the batch process.

Your software then loads the first image, carries out the commands that have been set in the macro, then saves the resulting image in the destination folder specified.

When the macro has been run through for the first image, the next image is loaded, and this is continued until all of the chosen images have been analyzed.

As soon as the batch process has been started, your software opens the Macro Batch Progress dialog box. This dialog box gives you information about how the batch process is progressing.

You can interrupt every batch process in this dialog box, or even stop it completely.

Additionally, you can see a progress bar that shows you when it is expected that the batch process will be completed.

This dialog box won't be automatically closed, so that you can find information on the batch process the following morning when you want to let a process run overnight.

In the Macro Batch Progress dialog box, check whether the batch process has analyzed all of the images you wanted. Should an image not have been successfully analyzed, you'll find a message there to that effect. In this case, your software will have continued the batch process with the following image.

Finishing the batch process

Close the Macro Batch Progress dialog box.

The batch process has then been completed

Click the Toggle Batch Mode button in the Macro Manager tool window's toolbar.

All of the Macro Manager tool window's functions are now once more available. You can now, for example, acquire new macros, or choose another macro for a batch process.

back to top

00343