DIPlib Documentation - ©1995-2017 Quantitative Imaging Group, Delft University of Technology.

Arith

arithmetic function

SYNOPSIS

dip_Error dip_Arith ( in1, in2, out, op, dt )

DATA TYPES

binary, integer, float, complex

FUNCTION

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.

ARGUMENTS

Data typeNameDescription
dip_Imagein1First input
dip_Imagein2Second input
dip_ImageoutOutput
dipf_ArithOperationopDyadic arithmetic operation
dip_DataTypedtData type for output

The dipf_ArithOperation flag can be one of:

NameDescription
DIP_ARITHOP_ADDAddition (in1+in2)
DIP_ARITHOP_SUBSubtraction (in1-in2)
DIP_ARITHOP_MULMultiplication (in1*in2)
DIP_ARITHOP_DIVDivision (in1/in2)
DIP_ARITHOP_MUL_CONJUGATEConjugate multiplication (in1*conj(in2))

For two binary inputs, and with dt = DIP_DT_FLEXBIN, the operations performed are equivalent to logical operations:

NameDescription
DIP_ARITHOP_ADDOr (in1|in2)
DIP_ARITHOP_SUBAnd not (in1&!in2)
DIP_ARITHOP_MULAnd (in1&in2)
DIP_ARITHOP_DIVXor (in1^in2)
DIP_ARITHOP_MUL_CONJUGATEAnd (in1&in2)

SEE ALSO

Arith_ComplexSeparated, Add, Sub, Mul, Div, MulConjugate, AddInteger, AddFloat, AddComplex, SubInteger, SubFloat, SubComplex, MulInteger, MulFloat, MulComplex, MulConjugateComplex, DivInteger, DivFloat, DivComplex