diplib/math.h file

Declares image math functions, except basic arithmetic and comparison. See diplib/library/operators.h, Math and statistics.

Contents

Functions

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::Sin(dip::Image const& in, dip::Image& out)
Computes the sine of each sample.
void dip::Cos(dip::Image const& in, dip::Image& out)
Computes the cosine of each sample.
void dip::Tan(dip::Image const& in, dip::Image& out)
Computes the tangent of each sample.
void dip::Asin(dip::Image const& in, dip::Image& out)
Computes the arc sine of each sample.
void dip::Acos(dip::Image const& in, dip::Image& out)
Computes the arc cosine of each sample.
void dip::Atan(dip::Image const& in, dip::Image& out)
Computes the arc tangent of each sample.
void dip::Sinh(dip::Image const& in, dip::Image& out)
Computes the hyperbolic sine of each sample.
void dip::Cosh(dip::Image const& in, dip::Image& out)
Computes the hyperbolic cosine of each sample.
void dip::Tanh(dip::Image const& in, dip::Image& out)
Computes the hyperbolic tangent of each sample.
void dip::BesselJ0(dip::Image const& in, dip::Image& out)
Computes the Bessel functions of the first kind of each sample, of order alpha = 0.
void dip::BesselJ1(dip::Image const& in, dip::Image& out)
Computes the Bessel functions of the first kind of each sample, of order alpha = 1.
void dip::BesselJN(dip::Image const& in, dip::Image& out, dip::uint alpha)
Computes the Bessel functions of the first kind of each sample, of order alpha.
void dip::BesselY0(dip::Image const& in, dip::Image& out)
Computes the Bessel functions of the second kind of each sample, of order alpha = 0.
void dip::BesselY1(dip::Image const& in, dip::Image& out)
Computes the Bessel functions of the second kind of each sample, of order alpha = 1.
void dip::BesselYN(dip::Image const& in, dip::Image& out, dip::uint alpha)
Computes the Bessel functions of the second kind of each sample, of order alpha.
void dip::LnGamma(dip::Image const& in, dip::Image& out)
Computes the natural logarithm of the gamma function of each sample.
void dip::Erf(dip::Image const& in, dip::Image& out)
Computes the error function of each sample.
void dip::Erfc(dip::Image const& in, dip::Image& out)
Computes the complementary error function of each sample.
void dip::Sinc(dip::Image const& in, dip::Image& out)
Computes the sinc function of each sample. \(\mathrm{sinc}(x) = \sin(x)/x\) .
void dip::IsNotANumber(dip::Image const& in, dip::Image& out)
True for each pixel that is NaN.
void dip::IsInfinite(dip::Image const& in, dip::Image& out)
True for each pixel that is positive or negative infinity.
void dip::IsFinite(dip::Image const& in, dip::Image& out)
True for each pixel that is not NaN nor infinity.
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.
void dip::Real(dip::Image const& in, dip::Image& out)
Returns the real component of a complex image. Returns dip::Image::Real if the input is complex.
void dip::Imaginary(dip::Image const& in, dip::Image& out)
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.
void dip::LinearCombination(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.
void dip::LinearCombination(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,
void dip::Atan2(dip::Image const& y, dip::Image const& x, dip::Image& out)
Computes the four-quadrant arc tangent of y/x.
void dip::Hypot(dip::Image const& a, dip::Image const& b, dip::Image& out)
Computes the square root of the sum of the squares of corresponding samples in a and b.
auto dip::Transpose(dip::Image const& in) -> dip::Image
Transposes the tensor image, the data are not copied.
void dip::ConjugateTranspose(dip::Image const& in, dip::Image& out)
Computes the conjugate transpose of the tensor image in.
void dip::DotProduct(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)
Computes the dot product (inner product) of two vector images.
void dip::CrossProduct(dip::Image const& lhs, dip::Image const& rhs, dip::Image& out)
Computes the cross product (inner product) of two vector images.
void dip::Norm(dip::Image const& in, dip::Image& out)
Computes the norm of the vector at each pixel in image in.
void dip::SquareNorm(dip::Image const& in, dip::Image& out)
Computes the square of the norm of the vector at each pixel in image in.
void dip::Angle(dip::Image const& in, dip::Image& out)
Computes the angle of the vector at each pixel in image in.
void dip::Orientation(dip::Image const& in, dip::Image& out)
Computes the orientation of the vector at each pixel in image in.
void dip::CartesianToPolar(dip::Image const& in, dip::Image& out)
Converts the vector at each pixel in image in from Cartesian coordinates to polar (or spherical) coordinates.
void dip::PolarToCartesian(dip::Image const& in, dip::Image& out)
Converts the vector at each pixel in image in from polar (or spherical) coordinates to Cartesian coordinates.
void dip::Determinant(dip::Image const& in, dip::Image& out)
Computes the determinant of the square matrix at each pixel in image in.
void dip::Trace(dip::Image const& in, dip::Image& out)
Computes the trace of the square matrix at each pixel in image in.
void dip::Rank(dip::Image const& in, dip::Image& out)
Computes the rank of the square matrix at each pixel in image in. The output is DT_UINT8, under the assumption that we won’t have tensor images with a rank higher than 255.
void dip::Eigenvalues(dip::Image const& in, dip::Image& out)
Computes the eigenvalues of the square matrix at each pixel in image in.
void dip::LargestEigenvalue(dip::Image const& in, dip::Image& out)
Finds the largest eigenvalue of the square matrix at each pixel in image in.
void dip::SmallestEigenvalue(dip::Image const& in, dip::Image& out)
Finds the smallest eigenvalue of the square matrix at each pixel in image in.
void dip::EigenDecomposition(dip::Image const& in, dip::Image& out, dip::Image& eigenvectors)
Computes the eigenvalues and eigenvectors of the square matrix at each pixel in image in.
void dip::LargestEigenvector(dip::Image const& in, dip::Image& out)
Finds the largest eigenvector of the symmetric matrix at each pixel in image in.
void dip::SmallestEigenvector(dip::Image const& in, dip::Image& out)
Finds the smallest eigenvector of the symmetric matrix at each pixel in image in.
void dip::Inverse(dip::Image const& in, dip::Image& out)
Computes the inverse of the square matrix at each pixel in image in.
void dip::PseudoInverse(dip::Image const& in, dip::Image& out, dip::dfloat tolerance = 1e-7)
Computes the pseudo-inverse of the matrix at each pixel in image in.
void dip::SingularValues(dip::Image const& in, dip::Image& out)
Computes the “thin” singular value decomposition of the matrix at each pixel in image in.
void dip::SingularValueDecomposition(dip::Image const& A, dip::Image& U, dip::Image& S, dip::Image& V)
Computes the “thin” singular value decomposition of the matrix at each pixel in image in.
void dip::Identity(dip::Image const& in, dip::Image& out)
Creates an image whose pixels are identity matrices.
void dip::SumTensorElements(dip::Image const& in, dip::Image& out)
Adds all tensor elements, producing a scalar image.
void dip::ProductTensorElements(dip::Image const& in, dip::Image& out)
Multiplies all tensor elements, producing a scalar image.
void dip::AllTensorElements(dip::Image const& in, dip::Image& out)
Determines if all tensor elements are non-zero, producing a binary scalar image.
void dip::AnyTensorElement(dip::Image const& in, dip::Image& out)
Determines if any tensor element is non-zero, producing a binary scalar image.
void dip::MaximumTensorElement(dip::Image const& in, dip::Image& out)
Takes the maximum tensor element at each pixel, producing a scalar image.
void dip::MaximumAbsTensorElement(dip::Image const& in, dip::Image& out)
Takes the maximum absolute tensor element at each pixel, producing a scalar image. For float and complex images only.
void dip::MinimumTensorElement(dip::Image const& in, dip::Image& out)
Takes the minimum tensor element at each pixel, producing a scalar image.
void dip::MinimumAbsTensorElement(dip::Image const& in, dip::Image& out)
Takes the minimum absolute tensor element at each pixel, producing a scalar image. For float and complex images only.
void dip::MeanTensorElement(dip::Image const& in, dip::Image& out)
Computes the mean tensor element value at each pixel, producing a scalar image.
void dip::GeometricMeanTensorElement(dip::Image const& in, dip::Image& out)
Computes the geometric mean tensor element value at each pixel, producing a scalar image.
void dip::SortTensorElements(dip::Image& out)
Sorts the tensor elements within each pixel from largest to smallest. Works in-place. out must be real-valued.
void dip::SortTensorElementsByMagnitude(dip::Image& out)
Sorts the tensor elements within each pixel by magnitude from largest to smallest. Works in-place. out must be of a floating point or complex type.
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.
void dip::Toggle(dip::Image const& in, dip::Image const& in1, dip::Image const& in2, dip::Image& out)
Writes to out whichever of in1 or in2 is closest to in.