Math and statistics » Comparison operators module

Monadic and dyadic image comparison operators.

Contents

Functions

void dip::Select(dip::Image const& in1, dip::Image const& in2, dip::Image const& in3, dip::Image const& in4, dip::Image& out, dip::String const& selector)
Compares in1 to in2 according to selector, and writes in3 or in4 to out depending on the result.
void dip::Select(dip::Image const& in1, dip::Image const& in2, dip::Image const& mask, dip::Image& out)
Writes either in1 or in2 to out depending on the value of mask.

Operators

template<typename T>
auto dip::operator==(dip::Image const& lhs, T const& rhs) -> dip::Image
Comparison operator, calls dip::Equal.
template<typename T>
auto dip::operator!=(dip::Image const& lhs, T const& rhs) -> dip::Image
Comparison operator, calls dip::NotEqual.
template<typename T>
auto dip::operator<(dip::Image const& lhs, T const& rhs) -> dip::Image
Comparison operator, calls dip::Lesser.
template<typename T>
auto dip::operator>(dip::Image const& lhs, T const& rhs) -> dip::Image
Comparison operator, calls dip::Greater.
template<typename T>
auto dip::operator<=(dip::Image const& lhs, T const& rhs) -> dip::Image
Comparison operator, calls dip::NotGreater.
template<typename T>
auto dip::operator>=(dip::Image const& lhs, T const& rhs) -> dip::Image
Comparison operator, calls dip::NotLesser.

Function documentation

void dip::Select(dip::Image const& in1, dip::Image const& in2, dip::Image const& in3, dip::Image const& in4, dip::Image& out, dip::String const& selector)

Compares in1 to in2 according to selector, and writes in3 or in4 to out depending on the result.

In short, this is the operation that is applied sample by sample:

in1 <selector> in2 ? in3 : in4

The string selector can be one of: “==”, “!=”, “>”, “<”, “>=”, “<=”

An alternative (slower) implementation would be:

dip::Image mask = in1 <selector> in2;
out = in4.Copy();
out.At( mask ) = in3.At( mask );

Note that all input images are singleton-expanded to match in size, so the function can e.g. be used with scalar values for in3 and in4:

    dip::Image result = dip::Select( in1, in2, dip::Image{ true }, dip::Image{ false }, "==" );

The above is an (less efficient) implementation of

dip::Image result = in1 == in2;

The output image has the same type as in3 and in4. If these types are different, the output type is given by

dip::DataType::SuggestDyadicOperation( in3.DataType(), in4.DataType() );

void dip::Select(dip::Image const& in1, dip::Image const& in2, dip::Image const& mask, dip::Image& out)

Writes either in1 or in2 to out depending on the value of mask.

In short, this is the operation that is applied sample by sample:

mask ? in1 : in2

An alternative (slower) implementation would be:

out = in2.Copy();
out.At( mask ) = in1.At( mask );

When out is the same image as in1, the operation becomes similar to (but faster than):

in1.At( !mask ) = in2.At( !mask );

Conversely, when out is the same image as in2, the operation becomes similar to (but faster than):

in2.At( mask) = in1.At( mask );

The output image has the same type as in1 and in2. If these types are different, the output type is given by

dip::DataType::SuggestDyadicOperation( in1.DataType(), in2.DataType() );