Image Arithmetic

Overview

Image Arithmetic calculates an output data set from one or two input data sets using one of several arithmetic operations. The inputs may be any combination of windows or files.

To create the result, select the operation, the coefficients, and whether or not to force values less than zero to zero. Then select the file or files on which to operate and the region of the file to process (these controls are the same as other region processing applications; see the region processing interface documentation for more information). When the parameters have been set, press DoIt to generate the result.

Image Arithmetic performs its internal calculations in floating-point arithmetic, but by default, the output is converted to the same data type as the first input file. In several cases, this may not be what you want and you should explicitly set the output type with the Mode control.

Topics

Overview | Region processing | Operators | Coefficients | Clamping to zero | Command line

Related Priism Topics

Priism | CopyRegion


Operators

There a fixed set of operations that Image Arithmetic can apply. The operations are applied independently to each pixel in the selected region. In terms of the two coefficients, A and B, the pixel value in file 1, X, and the pixel value in file 2, the available operations are:

Abs in the sixth operation takes the absolute value of a real quantity and the magnitude of a complex quantity. Conj in the fifth and seventh operations returns the complex conjugate of its argument.

All the calculations are done in floating-point arithmetic. When an operation produces a complex result but the output file does not use a complex data type, the imaginary part of the result is discarded and only the real part is stored.

Topics

Overview | Region processing | Operators | Coefficients | Clamping to zero | Command line


Coefficients

Image Arithmetic's operators use two coefficients. Coefficient A is substituted for A in the operator expressions; in general, it is applied to values from the first file. Coefficient B is substituted for B in the operator expressions; in general, it is applied to values from the second file.

Topics

Overview | Region processing | Operators | Coefficients | Clamping to zero | Command line


Clamping to zero

Set this toggle on if you want values less than zero from the arithmetic operation to be set to zero in the output (clamping). Clamping is only performed if the output is stored in a pure real format (byte, short, float, ushort, or long); if the output is complex, no clamping is done. When clamping is used with an operation that generates a complex value and the output data set is real, the clamping is only applied to the real component of the intermediate value (the imaginary component is discarded).

Topics

Overview | Region processing | Operators | Coefficients | Clamping to zero | Command line


Command Line

Image Arithmetic accepts the command-line arguments described in Region.html. In addition, Image Arithmetic has the following options (optional parts are shown in brackets):

-a=real_part[:imaginary_part]
Specifies the value substituted for A in the operator expressions. If the coefficient is to be purely real, only the first argument has to be supplied. If -a is not specified, one is substituted for the value of A.
-b=real_part[:imaginary_part]
Specifies the value substituted for B in the operator expressions. If the coefficient is to be purely real, only the first argument has to be supplied. If -b is not specified, one is substituted for the value of B.
-clamp
If specified and the output is stored in a pure real format (byte, short, float, ushort, or long), any values in the output less than zero are set to zero.
-operator=operator_name
Specifies the operation to be performed. Possible values for operator_name are listed below; a1+b2 is the default if -operator does not appear on the command line.
a1+b2
Computes input 1 multiplied by A plus input 2 multiplied by B.
a1-b2
Computes input 1 multiplied by A minus input 2 multiplied by B.
a1b2
Computes input 1 multiplied by A multiplied by input 2 multiplied by B.
a1/b2
Computes input 1 multiplied by A divided by the product of input 2 and B.
a1_conj_b2
Computes input 1 multiplied by A multiplied by the complex conjugate of the product of input 2 and B.
abs_a1
Computes the absolute value of the product of input 1 and A.
conj_a1
Computes the complex conjugate of the product of input 1 and A.
a1+b
Computes input 1 multiplied by A plus B.
a1b
Computes input 1 multiplied by A multiplied by B.
a/b2
Computes A divided by the product of B and input 2.

As an example, the command line below computes the ratio of the second wavelength to the first wavelength in window 1 and writes the result to window 2:

    ImgArith 1 1 2 -w1=1 -w2=0 -operator=a1/b2 -mode=float

Topics

Overview | Region processing | Operators | Coefficients | Clamping to zero | Command line