Changing Opacity and Automated Composite Merging.

How do you change opacity and perform a composite merge in an automation to merge Fluorescent and DIC or Phase images?

Dr Vipoir thought that this would be a most interesting topic for his tip this month.

After running a time lapse experiment to capture fluorescent and DIC images, it is a good idea to have an automation to process the merging operation, as doing this manually is likely to drive you insane.

I will demonstrate how to write an automation to do this. I will write the automation without the necessity to view specific layer names as we all know that everyone has their own naming convention.


Let's say that I have an image stack that contains alternately arranged DIC and GFP layers like this below.


Let's kick start the automation with a "Start" and "Target" task.


 

Target the top most image window and bring it to the top.


The next task is a non modal "Tell" task informing the user to view the first layer in the series; it also reminds the user that this automation will assume that the layers are all in the correct order.



Next, we have two more "Tell" tasks.

This one will ask how many image pairs the user wants to process. I have put the result into the variable "number of_pairs". I will use this to define the number loops.

The second "Tell" task will ask for the opacity value to be used, putting the value into a variable called "opacity".


 

The value that you enter for the opacity should be between 1 and 100%. See below - I will show you how to change this manually.


Ideally you should determine what figure to enter for the opacity before running this automation.

Now for the all important loop task.


We will loop "number_of_pairs" times putting the loop count into a variable called "count"

The "Merge to Composite" task requires the layers to be selected, therefore we will have to get the names of each layer in turn, select them, then merge to composite.

Firstly we will get the name of the first layer (DIC) and put it into a variable.


 


The opacity of this layer will also need to be changed before it is merged. To do this we use a "Set layer info" task.


Set the opacity to the variable "opacity".


 


We then use a "View layer" task, picking the "View next layer" option. This skips to the fluorescent layer and we also get the name of this layer. This name is put into the string variable "Layer2".

This is then followed by two layer selection tasks.

The first selects the layer with the name "Layer1" (string variable)


As you've guessed the second layer selection task selects the layer with the name "Layer2". Please note that the option "Leave current selection" is also selected.


This selects the two layers to be merged. We can now use the "Merge to Composite" task.


This task also automatically views the merged layer.

In order to merge the next pair of layers in the series we need to add two additional "View layer" tasks.

The first one views the layer "Layer2"


The second one will view the next layer so that the layer now being viewed is the next DIC layer to be processed.


So that completes today's lesson. The automation should look something like this:-

Adios, until next month!