Module: Arithmetic ()

Description:

The Arithmetic module performs calculations on up to three input data objects according to a user-defined arithmetic expression. The result is stored in a new data object called Result. The calculations are triggered by the Apply button. The arithmetic expression is evaluated either on the grid of the first data object (in case of regular, tetrahedral, or hexahedral grids or surfaces) or on a regular 3D uniform grid for which the number of points can be set by the Resolution port.

The module is able to process input fields with up to 6 different channels. Scalar input fields are referenced by the variables A, B, and C. The values of multi-component input fields are referenced for example by Ax, Ay, Az (if input A is a vector field) or Br, Bg, Bb, Ba (if input B is an RGBA color field).

In any case the expressions are evaluated per point, i.e., the result for a point (X,Y,Z) depends on input values at the same point only. If the resulting object is based on a regular grid, grid indices I, J, or K may also appear in the arithmetic expression. This means that for each grid point its associated I, J, or K index value will be substituted in the arithmetic expression on evaluation. This is useful in connection with comparison operators which produce a result of either zero or one. Computations may be confined to a specific sub-grid this way.

An expression consists of variables and mathematical and logical operators. The syntax is basically the same as for C expressions. The following variables are defined:

This is the list of available mathematical and logical operators:

There are also some built-in functions:

For better understanding some examples of how to use the Arithmetic module follow:

Expression: A
The result is a copy of input object A. If A is defined on a tetrahedral or hexahedral grid and the result type is set to regular together with an appropriate resolution, the expression leads to a conversion from an unstructured grid to a structured regular grid. The same trick can also be used to resample a regular field with stacked coordinates onto a uniform grid.

Expression: A-B
The result is the difference between input objects A and B. This expression is sometimes useful in order to compare two different data sets.

Expression: 255*(A>127)
Simple thresholding: For every value of A the result is set to 255 if the value is greater than 127. Otherwise the result is 0.

Expression: A*(B>0)
Simple masking operation: If B is zero, the result is also set to zero. Otherwise, the result is set to A. For example, if A is a 3D image and B is a corresponding label image, the exterior parts of the object (where B is zero) are masked out by this expression.

Connections:

InputA [required]
The input may either be a 3D data field with an arbitrary number of channels or a tetrahedral or hexahedral grid. The primitive data type of the result will be the same as this input, e.g., if input A contains bytes the result will also contain bytes.

The input may also be a surface field or a surface itself. For example, you may want to capture the values of a 3D data field at all points of a surface in a surface field. However, note that data on surfaces can only be used as input if the output is defined on the same surface. Trying to evaluate a surface field for points of a 3D grid or for points of some other surface is not possible, even if these points lie exactly on the source surface.

InputB [optional]
Second input, can be any 3D data field or surface field.

InputC [optional]
Third input, can be any 3D data field or surface field.

Ports:

Result Type

With this radio box the grid type of the result can be set either to either the same as input A or to a regular grid with uniform coordinates.

Result Location

Specify the location of the result. Produces either a value for every vertex of the grid (on Nodes), or for every grid cell (on Cell Center). This port is available if the first input connection is of type Surface, Tetra Grid or Hexa Grid.

Resolution

If port Result Type is set to regular, the resolution of the regular field to be generated is set to the values given here.

Min Box

Port to set the minimum x-, y-, z-coordinates of a bounding box around the output data object. If one or more input data objects are connected, the bounding box of the first input data object is also taken as the output bounding box.

Max Box

Port to set maximum x-, y-, z-coordinates of the bounding box around the output data object.

Options

Ignore errors: Tell the Arithmetic module to ignore errors. For example, this can be useful to force the computation of divisions if the data contains zeros.

Result Channels

Result Channels

This port determines the number of channels of the result. By default, the result has the same number of channels as input A. Alternatively, you can specify that the result should have 2 channels (complex scalar field), 3 channels (vector field), 4 channels (RGBA color field), or 6 channels (either a complex vector or a symmetric tensor field of second order).

Expression

This port specifies the mathematical expression used to compute the result. If the result has more than one channel, more expression ports will be shown.