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

# macros.h

Various macros

## DESCRIPTION

The include files `dip_macros.h` contains a number of useful macros.

Math macros

`DIP_ABS( x )` | Absolute value of `x`
`DIP_MAX( x, y )` | Maximum of `x` and `y`
`DIP_MIN( x, y )` | Minimum of `x` and `y`
`DIP_FUNC( funcName, suffix )` | Attaches the suffix to the function name, and puts and underscore in between.
`DIP_SWAP( x, y, z )` | Swaps variables `x` and `y`, using temporary variable `z`. Must be followed by a trailing ";"

Macros for handling complex numbers:

`DIP_REAL( x )` | Real part of complex number `x`
`DIP_IMAGINARY( x )` | Imaginary part of complex number `x`
`DIP_SQUARE_MODULUS( x )` | Square modulus of complex number `x`
`DIP_MODULUS( x )` | Modulus of complex number `x`
`DIP_PHASE( x )` | Phase of complex number `x`

Binary I/O macros

`DIP_BINARY_MASK( mask, plane )` | Computes a binary `mask` from the `plane` value
`DIP_BINARY_READ( in, mask )` | Returns the binary value from `in`
`DIP_BINARY_WRITE( out, val, mask )` | Writes the value of `val` to `out`

Random access I/O macros:

    DIP_PIXEL_GET( ip, pos, stride, value )
    DIP_PIXEL_SET( ip, pos, stride, value )

get/set the `value` of the pixel at position `pos` from data pointer `ip` with strides `stride`. Both `pos` and `stride` are `dip_IntegerArray`s.

    DIP_PIXEL_ADD( ip, pos, stride, value )
    DIP_PIXEL_SUB( ip, pos, stride, value )
    DIP_PIXEL_MUL( ip, pos, stride, value )
    DIP_PIXEL_DIV( ip, pos, stride, value )

add/subtract/multlipy/divide the `value` with the pixel-value at position `pos` from data pointer `ip` with strides `stride`. Both `pos` and `stride` are `dip_IntegerArray`s.