Annotations III: Modifying and merging
Explains how to modify the set of annotations
Tutorial: Annotations III (Modifying and merging)
In this tutorial we will work with a generated image, which is a quick and convenient way to test various features.
Begin by adding the node
Add data > Image > Generate from math expression
Generate from math expression generates an image with a user-defined size and generates the value via a custom math expression.
Adding the node
Annotate by image statistics (Expression) and configure the
Generated annotations parameter in its parameter tab as following:
stat_mean(the mean intensity value; click
Editto find out more about variables)
MeanIntensity(the column name refers to the name of the generated annotation)
If you run the node via
Update cache, you will see a new annotation
Auto threshold 2D node and run it with
Observe that the set of annotations include both the calculated
Threshold and the
MeanIntensity value that was generated in the last step.
Let’s calculate the difference between the threshold and the mean image intensity.
Add a node
Set/Edit annotations and navigate to its
- Set the
ABS(TO_NUMBER(MeanIntensity) - TO_NUMBER(Threshold))
- Set the
On running the node you should notice a new annotation
ThresholdDiff that is set to the absolute difference between the threshold and mean image intensity.
Set/Edit annotations allows you to create new annotations by setting their value and to combine existing annotations or apply operations on them.
TO_NUMBER is required, as JIPipe annotations can only store text. Thus, they must be converted to numbers if you want to apply mathematical operations.
Let’s assume that we need the
ThresholdDiff annotation in an earlier step (the raw image) or even completely different “branch” of processed data. JIPipe provides a node to copy annotations between two data sets:
Begin by adding
Merge annotations into the graph and navigate to the
Examples tab. Here, load the example
Merge annotations (2 inputs) for convenience. Alternatively, you can create the inputs yourself.
Set/Edit annotations output to one of the
Merge annotations inputs, and the
Generate from math expression output to the other.
Merge annotations node with
Update cache and observe that the raw input image was annotated with information generated at a later step.
Now let’s assume that we do not need
MeanIntensity again. These can be removed via dedicated nodes.
Add a node
Remove annotation and configure its
Removed annotations parameter as following:
key == "Threshold" OR key == "MeanIntensity"
This will remove all annotations that either have the name/key
Remove annotation executes the expression for each annotation to determine if it should be deleted.
You can also remove annotations by their value or implement even more complex filter expressions.
Remove annotation node with
Update cache. The unwanted columns are now removed.