arithmetic function
dip_Error dip_Arith ( in1, in2, out, op, dt )
binary, integer, float, complex
This function computes out = in1 op in2 on a pixel by pixel basis. The data types of the in1 and in2 image may be of different types. dt may be any of DIPlib's data types, or the constants DIP_DT_MINIMUM, DIP_DT_FLEX or DIP_DT_FLEXBIN, and determines what the output data type will be. DIP_DT_MINIMUM selects a data type according to the default for dyadic operations, see Information about dyadic operations for more information. DIP_DT_FLEX will choose a floating point (real or complex) type, the precision depends on the input types. DIP_DT_FLEXBIN is the same as DIP_DT_FLEX, except that two binary inputs will produce a binary output.
Data type | Name | Description |
dip_Image | in1 | First input |
dip_Image | in2 | Second input |
dip_Image | out | Output |
dipf_ArithOperation | op | Dyadic arithmetic operation |
dip_DataType | dt | Data type for output |
The dipf_ArithOperation flag can be one of:
Name | Description |
DIP_ARITHOP_ADD | Addition (in1+in2) |
DIP_ARITHOP_SUB | Subtraction (in1-in2) |
DIP_ARITHOP_MUL | Multiplication (in1*in2) |
DIP_ARITHOP_DIV | Division (in1/in2) |
DIP_ARITHOP_MUL_CONJUGATE | Conjugate multiplication (in1*conj(in2)) |
For two binary inputs, and with dt = DIP_DT_FLEXBIN, the operations performed are equivalent to logical operations:
Name | Description |
DIP_ARITHOP_ADD | Or (in1|in2) |
DIP_ARITHOP_SUB | And not (in1&!in2) |
DIP_ARITHOP_MUL | And (in1&in2) |
DIP_ARITHOP_DIV | Xor (in1^in2) |
DIP_ARITHOP_MUL_CONJUGATE | And (in1&in2) |
Arith_ComplexSeparated, Add, Sub, Mul, Div, MulConjugate, AddInteger, AddFloat, AddComplex, SubInteger, SubFloat, SubComplex, MulInteger, MulFloat, MulComplex, MulConjugateComplex, DivInteger, DivFloat, DivComplex