You are here: Start » User Interface » Performing General Calculations
Performing General Calculations
Introduction
Apart from using image processing or computer vision tools, most often it is also necessary to perform some general calculations on numeric values or geometrical coordinates. There are two ways to do this in FabImage Studio:
 Using filters from the Standard Library.
 Using special formula blocks.
Example
Let us assume that we need to compute the hypotenuse \(\sqrt{a^2 + b^2}\). Here are the two possible solutions:
The second approach, using formula blocks, is the most recommended. Data flow programming is just not well suited for numerical calculations and standard formulas, which can be defined directly in formula blocks, are much easier to read and understand. You can also think of this feature as an ability to embed little spreadsheets into your machine vision algorithms.
Creating Formula Blocks
To create a formula block:

Drag and drop the Formula tool from the Toolbox (Logic & Math section) to the Program Editor:

Add inputs and outputs using the context menu or by clicking Add Input and Add Output links:

For each input define the name and the type:

In order to create an output, first press Add Output button. It will create a new output with template name: outName:
Replace the highlighted Name with meaningful name. While typing a Tooltip with available options should appear:
Example usage of each option:
 After the name type equal sign = and the expression. There is no need to define a type of output. The type will be assigned automatically.
 After the name add as followed by LabelName. This label will later appear as a formula output.
 After the name add label as described in the previous point. Then add colon : and directly specify the output type:
 In the last option output type is defined directly. After the name add colon : and directly specify the output type:
Final formula should look like this:
 After the name type equal sign = and the expression. There is no need to define a type of output. The type will be assigned automatically.
Remarks
 Existing formulas can also be edited directly in a formula block in the Program Editor.
 It is also possible to create new inputs and outputs by dragging and dropping connections onto a formula block.
 Formula blocks containing incorrect formulas are marked with red background. Programs containing such filters cannot be run.
 When defining a formula for an output it is possible to use other outputs, provided that they are defined earlier. The order can be changed through the outputs context menu.
 For efficiency reasons it is advisable not to use "heavy" objects in formulas, such as images or regions.
Syntax and Semantics
For complete information about the syntax and semantics please refer to the Formulas article in the Programming Reference.
Previous: Remote Access to the Runtime Application  Next: Managing Projects with Project Explorer 