# Math and statistics » Arithmetic operators module

• Reference

## Functions

void dip::Add(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Adds two images, sample-wise, with singleton expansion, and using saturated arithmetic.
void dip::Subtract(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Subtracts two images, sample-wise, with singleton expansion, and using saturated arithmetic.
void dip::Multiply(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Multiplies two images, pixel-wise, with singleton expansion, and using saturated arithmetic.
dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Multiplies two images, sample-wise, with singleton expansion, and using saturated arithmetic.
dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Multiplies two images with complex conjugation, sample-wise, with singleton expansion.
void dip::Divide(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Divides two images, sample-wise, with singleton expansion.
void dip::SafeDivide(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Divides two images, sample-wise, with singleton expansion. Tests for division by zero, filling in 0 instead.
void dip::Modulo(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Computes the modulo of two images, sample-wise, with singleton expansion.
void dip::Power(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)
Elevates `lhs` to the power of `rhs`, sample-wise, with singleton expansion.
void dip::Invert(dip::Image const& in, dip::Image& out)
Inverts each sample of the input image, yielding an image of the same type.
void dip::And(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)
Bit-wise AND of two integer images, or logical AND of two binary images, sample-wise, with singleton expansion.
void dip::Or(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)
Bit-wise OR of two integer images, or logical OR of two binary images, sample-wise, with singleton expansion.
void dip::Xor(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)
Bit-wise XOR of two integer images, or logical XOR of two binary images, sample-wise, with singleton expansion.
void dip::Not(dip::Image const& in, dip::Image& out)
Bit-wise NOT of an integer image, or logical NOT of a binary image, sample-wise.
void dip::FlushToZero(dip::Image const& in, dip::Image& out)
Flushes denormal sample values to zero. Denormal floating-point values can slow down computation. Only defined for floating-point types, the output is the same type.
void dip::Round(dip::Image const& in, dip::Image& out)
Computes the nearest integer to each sample (rounds). Only defined for floating-point types, the output is the same type.
void dip::Ceil(dip::Image const& in, dip::Image& out)
Computes the smallest integer larger or equal to each sample (rounds up). Only defined for floating-point types, the output is the same type.
void dip::Floor(dip::Image const& in, dip::Image& out)
Computes the largest integer smaller or equal to each sample (rounds down). Only defined for floating-point types, the output is the same type.
void dip::Truncate(dip::Image const& in, dip::Image& out)
Computes the truncated value of each sample (rounds towards zero). Only defined for floating-point types, the output is the same type.
void dip::Fraction(dip::Image const& in, dip::Image& out)
Computes the fractional value of each sample (`out = in - dip::Truncate(in)`). Only defined for floating-point types, the output is the same type.
void dip::Reciprocal(dip::Image const& in, dip::Image& out)
Computes the reciprocal of each sample: `out = in == 0 ? 0 : 1/in`.
void dip::Square(dip::Image const& in, dip::Image& out)
Computes the square of each sample.
void dip::Sqrt(dip::Image const& in, dip::Image& out)
Computes the square root of each sample.
void dip::Exp(dip::Image const& in, dip::Image& out)
Computes the base e exponent (natural exponential) of each sample.
void dip::Exp2(dip::Image const& in, dip::Image& out)
Computes the base 2 exponent of each sample.
void dip::Exp10(dip::Image const& in, dip::Image& out)
Computes the base 10 exponent of each sample.
void dip::Ln(dip::Image const& in, dip::Image& out)
Computes the natural logarithm (base e logarithm) of each sample.
void dip::Log2(dip::Image const& in, dip::Image& out)
Computes the base 2 logarithm of each sample.
void dip::Log10(dip::Image const& in, dip::Image& out)
Computes the base 10 logarithm of each sample.
void dip::Abs(dip::Image const& in, dip::Image& out)
Computes the absolute value of each sample.
void dip::Modulus(dip::Image const& in, dip::Image& out)
Computes the modulus (absolute value) of each sample. `dip::Modulus` is an alias for `dip::Abs`.
void dip::SquareModulus(dip::Image const& in, dip::Image& out)
Computes the square of the modulus of each sample.
void dip::Phase(dip::Image const& in, dip::Image& out)
Computes the phase (angle on complex plane, through `std::arg`) of each sample.
auto dip::Real(dip::Image const& in) -> dip::Image
Returns the real component of a complex image. Returns `dip::Image::Real` if the input is complex.
auto dip::Imaginary(dip::Image const& in) -> dip::Image
Returns the imaginary component of a complex image. Returns `dip::Image::Imaginary` if the input is complex
void dip::Conjugate(dip::Image const& in, dip::Image& out)
Computes the complex conjugate of each sample.
void dip::Sign(dip::Image const& in, dip::Image& out)
Computes the sign of each sample. Only defined for signed real data types (signed integers and floating-point types). Output is of type `dip::DT_SINT8`, containing values -1, 0 and 1.
void dip::NearestInt(dip::Image const& in, dip::Image& out)
Computes the integer closest to the value of each sample. Only defined for floating-point types, the output is of type `dip::DT_SINT32`.
void dip::Supremum(dip::ImageConstRefArray const& in, dip::Image& out)
Computes the sample-wise supremum (maximum) over all the input images. For binary images, this is the same as the union.
void dip::Supremum(dip::Image const& a, dip::Image const& b, dip::Image& out)
Computes the sample-wise supremum (maximum) of the two input images. For binary images, this is the same as the union.
void dip::Infimum(dip::ImageConstRefArray const& in, dip::Image& out)
Computes the sample-wise infimum (minimum) over all the input images. For binary images, this is the same as the intersection.
void dip::Infimum(dip::Image const& a, dip::Image const& b, dip::Image& out)
Computes the sample-wise infimum (minimum) of the two input images. For binary images, this is the same as the intersection.
void dip::SignedInfimum(dip::Image const& a, dip::Image const& b, dip::Image& out)
Computes the sample-wise signed infimum (minimum) of the two input images: returns `-b` where `b < a`, a otherwise.
dip::Image const& a, dip::Image const& b, dip::Image& out, dip::dfloat aWeight = 0.5, dip::dfloat bWeight = 0.5)
Computes the linear combination of the two images, sample-wise.
dip::Image const& a, dip::Image const& b, dip::Image& out, dip::dcomplex aWeight, dip::dcomplex bWeight)
Computes the linear combination of the two complex images, sample-wise, yielding a complex output,

## Operators

template<typename T1, typename T2, typename <SFINAE> = T1>
auto dip::operator+(T1 const& lhs, T2 const& rhs) -> dip::Image
Arithmetic operator, calls `dip::Add`.
template<typename T1, typename T2, typename <SFINAE> = T1>
auto dip::operator-(T1 const& lhs, T2 const& rhs) -> dip::Image
Arithmetic operator, calls `dip::Subtract`.
template<typename T1, typename T2, typename <SFINAE> = T1>
auto dip::operator*(T1 const& lhs, T2 const& rhs) -> dip::Image
Arithmetic operator, calls `dip::Multiply`.
template<typename T1, typename T2, typename <SFINAE> = T1>
auto dip::operator/(T1 const& lhs, T2 const& rhs) -> dip::Image
Arithmetic operator, calls `dip::Divide`.
template<typename T1, typename T2, typename <SFINAE> = T1>
auto dip::operator%(T1 const& lhs, T2 const& rhs) -> dip::Image
Arithmetic operator, calls `dip::Modulo`.
template<typename T>
auto dip::operator&(dip::Image const& lhs, T const& rhs) -> dip::Image
Bit-wise and logical operator, calls `dip::And`.
template<typename T>
auto dip::operator|(dip::Image const& lhs, T const& rhs) -> dip::Image
Bit-wise and logical operator, calls `dip::Or`.
template<typename T>
auto dip::operator^(dip::Image const& lhs, T const& rhs) -> dip::Image
Bit-wise and logical operator, calls `dip::Xor`.
auto dip::operator+(dip::Image const& in) -> dip::Image
Unary operator, converts binary image to `dip::DT_UINT`, leaves other images unchanged.
auto dip::operator-(dip::Image const& in) -> dip::Image
Unary operator, calls `dip::Invert`.
auto dip::operator~(dip::Image const& in) -> dip::Image
Bit-wise and logical unary operator, calls `dip::Not`.
auto dip::operator!(dip::Image const& in) -> dip::Image
Logical unary operator. The input is converted to a binary image, then calls `dip::Invert`.
template<typename T>
auto dip::operator+=(dip::Image& lhs, T const& rhs) -> dip::Image&
Compound assignment operator, calls `dip::Add`.
template<typename T>
auto dip::operator-=(dip::Image& lhs, T const& rhs) -> dip::Image&
Compound assignment operator, calls `dip::Subtract`.
template<typename T>
auto dip::operator*=(dip::Image& lhs, T const& rhs) -> dip::Image&
Compound assignment operator, calls `dip::Multiply`.
template<typename T>
auto dip::operator/=(dip::Image& lhs, T const& rhs) -> dip::Image&
Compound assignment operator, calls `dip::Divide`.
template<typename T>
auto dip::operator%=(dip::Image& lhs, T const& rhs) -> dip::Image&
Compound assignment operator, calls `dip::Modulo`.
template<typename T>
auto dip::operator&=(dip::Image& lhs, T const& rhs) -> dip::Image&
Bit-wise compound assignment operator, calls `dip::And`.
template<typename T>
auto dip::operator|=(dip::Image& lhs, T const& rhs) -> dip::Image&
Bit-wise compound assignment operator, calls `dip::Or`.
template<typename T>
auto dip::operator^=(dip::Image& lhs, T const& rhs) -> dip::Image&
Bit-wise compound assignment operator, calls `dip::Xor`.

## Function documentation

### void dip::Add(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Adds two images, sample-wise, with singleton expansion, and using saturated arithmetic.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out. Pixel values from both images will be cast to type `dt` before applying the operation.

For binary types, saturated addition is equivalent to the Boolean OR operation.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::Subtract(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Subtracts two images, sample-wise, with singleton expansion, and using saturated arithmetic.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out. Pixel values from both images will be cast to type `dt` before applying the operation.

For binary types, saturated subtraction is equivalent to the Boolean AND NOT operation.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::Multiply(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Multiplies two images, pixel-wise, with singleton expansion, and using saturated arithmetic.

Tensor dimensions of the two images must have identical inner dimensions, and the output at each pixel will be the matrix multiplication of the two input pixels.

To obtain a sample-wise multiplication, Use `dip::MultiplySampleWise` instead.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out.

For binary types, saturated multiplication is equivalent to the Boolean AND operation.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::MultiplySampleWise(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Multiplies two images, sample-wise, with singleton expansion, and using saturated arithmetic.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out.

`rhs` can be a scalar value of any of the supported pixel types.

For binary types, saturated multiplication is equivalent to the Boolean AND operation.

### void dip::MultiplyConjugate(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Multiplies two images with complex conjugation, sample-wise, with singleton expansion.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out.

‘rhs’ will be complex-conjugated before the multiplication. This requires that it is complex and that `dt` is a complex type. Otherwise, `dip::MultiplySampleWise` will be called instead.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::Divide(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Divides two images, sample-wise, with singleton expansion.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out.

For binary types, saturated division is equivalent to the Boolean OR NOT operation.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::SafeDivide(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Divides two images, sample-wise, with singleton expansion. Tests for division by zero, filling in 0 instead.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out.

For binary images, this function calls `dip::Divide`.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::Modulo(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Computes the modulo of two images, sample-wise, with singleton expansion.

The image `out` will have the type `dt`, which defaults to `lhs.DataType()` if left out. Works for all real types (i.e. not complex). For floating-point types, uses `std::fmod`. Pixel values from both images will be cast to type `dt` (with saturation as usual) before applying the modulo operation, which might yield surprising results if `lhs` is an integer type and `rhs` has a fractional component, or if `rhs` saturates in the cast.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::Power(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out, dip::DataType dt)#include "diplib.h"

Elevates `lhs` to the power of `rhs`, sample-wise, with singleton expansion.

The image `out` will have the type `dt`, which defaults to `dip::DataType::SuggestArithmetic( lhs.DataType(), rhs.DataType() )` if left out.

Either `lhs` or `rhs` can be a scalar value of any of the supported pixel types, as long as at least one input is an image.

### void dip::Invert(dip::Image const& in, dip::Image& out)#include "diplib.h"

Inverts each sample of the input image, yielding an image of the same type.

For unsigned images, the output is `std::numeric_limits::max() - in`. For signed and complex types, it is `0 - in`. For binary images it is the logical NOT.

### void dip::And(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)#include "diplib.h"

Bit-wise AND of two integer images, or logical AND of two binary images, sample-wise, with singleton expansion.

Out will have the type of `lhs`, and `rhs` will be converted to that type before applying the operation. `lhs` must be an image, but `rhs` can also be a pixel or a sample (or a scalar value that implicitly converts to one).

### void dip::Or(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)#include "diplib.h"

Bit-wise OR of two integer images, or logical OR of two binary images, sample-wise, with singleton expansion.

Out will have the type of `lhs`, and `rhs` will be converted to that type before applying the operation. `lhs` must be an image, but `rhs` can also be a pixel or a sample (or a scalar value that implicitly converts to one).

### void dip::Xor(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)#include "diplib.h"

Bit-wise XOR of two integer images, or logical XOR of two binary images, sample-wise, with singleton expansion.

XOR is “exclusive or”.

Out will have the type of `lhs`, and `rhs` will be converted to that type before applying the operation. `lhs` must be an image, but `rhs` can also be a pixel or a sample (or a scalar value that implicitly converts to one).

### void dip::Not(dip::Image const& in, dip::Image& out)#include "diplib.h"

Bit-wise NOT of an integer image, or logical NOT of a binary image, sample-wise.

Out will have the type of `in`.

For binary images, this function calls `dip::Invert`.

### void dip::FlushToZero(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Flushes denormal sample values to zero. Denormal floating-point values can slow down computation. Only defined for floating-point types, the output is the same type.

### void dip::Round(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the nearest integer to each sample (rounds). Only defined for floating-point types, the output is the same type.

### void dip::Ceil(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the smallest integer larger or equal to each sample (rounds up). Only defined for floating-point types, the output is the same type.

### void dip::Floor(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the largest integer smaller or equal to each sample (rounds down). Only defined for floating-point types, the output is the same type.

### void dip::Truncate(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the truncated value of each sample (rounds towards zero). Only defined for floating-point types, the output is the same type.

### void dip::Fraction(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the fractional value of each sample (`out = in - dip::Truncate(in)`). Only defined for floating-point types, the output is the same type.

### void dip::Reciprocal(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the reciprocal of each sample: `out = in == 0 ? 0 : 1/in`.

### void dip::Square(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the square of each sample.

### void dip::Sqrt(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the square root of each sample.

### void dip::Exp(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the base e exponent (natural exponential) of each sample.

### void dip::Exp2(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the base 2 exponent of each sample.

### void dip::Exp10(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the base 10 exponent of each sample.

### void dip::Ln(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the natural logarithm (base e logarithm) of each sample.

### void dip::Log2(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the base 2 logarithm of each sample.

### void dip::Log10(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the base 10 logarithm of each sample.

### void dip::Abs(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the absolute value of each sample.

### void dip::Modulus(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the modulus (absolute value) of each sample. `dip::Modulus` is an alias for `dip::Abs`.

### void dip::SquareModulus(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the square of the modulus of each sample.

### void dip::Phase(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the phase (angle on complex plane, through `std::arg`) of each sample.

### dip::Image dip::Real(dip::Image const& in)#include "diplib/math.h"

Returns the real component of a complex image. Returns `dip::Image::Real` if the input is complex.

### dip::Image dip::Imaginary(dip::Image const& in)#include "diplib/math.h"

Returns the imaginary component of a complex image. Returns `dip::Image::Imaginary` if the input is complex

### void dip::Conjugate(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the complex conjugate of each sample.

### void dip::Sign(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the sign of each sample. Only defined for signed real data types (signed integers and floating-point types). Output is of type `dip::DT_SINT8`, containing values -1, 0 and 1.

### void dip::NearestInt(dip::Image const& in, dip::Image& out)#include "diplib/math.h"

Computes the integer closest to the value of each sample. Only defined for floating-point types, the output is of type `dip::DT_SINT32`.

### void dip::Supremum(dip::ImageConstRefArray const& in, dip::Image& out)#include "diplib/math.h"

Computes the sample-wise supremum (maximum) over all the input images. For binary images, this is the same as the union.

### void dip::Supremum(dip::Image const& a, dip::Image const& b, dip::Image& out)#include "diplib/math.h"

Computes the sample-wise supremum (maximum) of the two input images. For binary images, this is the same as the union.

### void dip::Infimum(dip::ImageConstRefArray const& in, dip::Image& out)#include "diplib/math.h"

Computes the sample-wise infimum (minimum) over all the input images. For binary images, this is the same as the intersection.

### void dip::Infimum(dip::Image const& a, dip::Image const& b, dip::Image& out)#include "diplib/math.h"

Computes the sample-wise infimum (minimum) of the two input images. For binary images, this is the same as the intersection.

### void dip::SignedInfimum(dip::Image const& a, dip::Image const& b, dip::Image& out)#include "diplib/math.h"

Computes the sample-wise signed infimum (minimum) of the two input images: returns `-b` where `b < a`, a otherwise.

### void dip::LinearCombination(dip::Image const& a, dip::Image const& b, dip::Image& out, dip::dfloat aWeight = 0.5, dip::dfloat bWeight = 0.5)#include "diplib/math.h"

Computes the linear combination of the two images, sample-wise.

The actual operation applied is:

```out = a * aWeight + b * bWeight;
```

With defaults weights of 0.5, the function computes the average of two images.

### void dip::LinearCombination(dip::Image const& a, dip::Image const& b, dip::Image& out, dip::dcomplex aWeight, dip::dcomplex bWeight)#include "diplib/math.h"

Computes the linear combination of the two complex images, sample-wise, yielding a complex output,

The actual operation applied is:

```out = a * aWeight + b * bWeight;
```

The images `a` and `b` do not necessarily need to be complex, but the computation will be performed with complex arithmetic.

### #include "diplib.h" template<typename T1, typename T2, typename <SFINAE> = T1> dip::Image dip::operator+(T1 const& lhs, T2 const& rhs)

Arithmetic operator, calls `dip::Add`.

### #include "diplib.h" template<typename T1, typename T2, typename <SFINAE> = T1> dip::Image dip::operator-(T1 const& lhs, T2 const& rhs)

Arithmetic operator, calls `dip::Subtract`.

### #include "diplib.h" template<typename T1, typename T2, typename <SFINAE> = T1> dip::Image dip::operator*(T1 const& lhs, T2 const& rhs)

Arithmetic operator, calls `dip::Multiply`.

### #include "diplib.h" template<typename T1, typename T2, typename <SFINAE> = T1> dip::Image dip::operator/(T1 const& lhs, T2 const& rhs)

Arithmetic operator, calls `dip::Divide`.

### #include "diplib.h" template<typename T1, typename T2, typename <SFINAE> = T1> dip::Image dip::operator%(T1 const& lhs, T2 const& rhs)

Arithmetic operator, calls `dip::Modulo`.

### #include "diplib.h" template<typename T> dip::Image dip::operator&(dip::Image const& lhs, T const& rhs)

Bit-wise and logical operator, calls `dip::And`.

### #include "diplib.h" template<typename T> dip::Image dip::operator|(dip::Image const& lhs, T const& rhs)

Bit-wise and logical operator, calls `dip::Or`.

### #include "diplib.h" template<typename T> dip::Image dip::operator^(dip::Image const& lhs, T const& rhs)

Bit-wise and logical operator, calls `dip::Xor`.

### dip::Image dip::operator+(dip::Image const& in)#include "diplib.h"

Unary operator, converts binary image to `dip::DT_UINT`, leaves other images unchanged.

### dip::Image dip::operator-(dip::Image const& in)#include "diplib.h"

Unary operator, calls `dip::Invert`.

### dip::Image dip::operator~(dip::Image const& in)#include "diplib.h"

Bit-wise and logical unary operator, calls `dip::Not`.

### dip::Image dip::operator!(dip::Image const& in)#include "diplib.h"

Logical unary operator. The input is converted to a binary image, then calls `dip::Invert`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator+=(dip::Image& lhs, T const& rhs)

Compound assignment operator, calls `dip::Add`.

Equivalent, but usually faster, than `lhs = lhs + rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator-=(dip::Image& lhs, T const& rhs)

Compound assignment operator, calls `dip::Subtract`.

Equivalent, but usually faster, than `lhs = lhs - rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator*=(dip::Image& lhs, T const& rhs)

Compound assignment operator, calls `dip::Multiply`.

Equivalent, but usually faster, than `lhs = lhs * rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator/=(dip::Image& lhs, T const& rhs)

Compound assignment operator, calls `dip::Divide`.

Equivalent, but usually faster, than `lhs = lhs / rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator%=(dip::Image& lhs, T const& rhs)

Compound assignment operator, calls `dip::Modulo`.

Equivalent, but usually faster, than `lhs = lhs % rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator&=(dip::Image& lhs, T const& rhs)

Bit-wise compound assignment operator, calls `dip::And`.

Equivalent, but usually faster, than `lhs = lhs & rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator|=(dip::Image& lhs, T const& rhs)

Bit-wise compound assignment operator, calls `dip::Or`.

Equivalent, but usually faster, than `lhs = lhs | rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.

### #include "diplib.h" template<typename T> dip::Image& dip::operator^=(dip::Image& lhs, T const& rhs)

Bit-wise compound assignment operator, calls `dip::Xor`.

Equivalent, but usually faster, than `lhs = lhs ^ rhs`.

The operation is performed in-place only if size is not changed by the operation. Singleton expansion could change the size of `lhs`.