dip::CovarianceMatrix class

A 2D covariance matrix for computation with 2D vertices.

The matrix is real, symmetric, positive semidefinite. See dip::Polygon::CovarianceMatrix for how to create a covariance matrix.

The elements stored are xx, xy and yy, with xx the top-left element, and xy both the off-diagonal elements, which are equal by definition.

Constructors, destructors, assignment and conversion operators

CovarianceMatrix() defaulted
Default-initialized covariance matrix is all zeros.
CovarianceMatrix(dip::VertexFloat v) explicit
Construct a covariance matrix as the outer product of a vector and itself.
CovarianceMatrix(dip::dfloat xx, dip::dfloat yy, dip::dfloat xy) explicit
Construct a covariance matrix with the three components.

Classes

struct Eigenvalues
Container for matrix eigenvalues.
struct EllipseParameters
Container for ellipse parameters.

Functions

auto xx() const -> dip::dfloat
Read matrix element.
auto xy() const -> dip::dfloat
Read matrix element.
auto yy() const -> dip::dfloat
Read matrix element.
auto Det() const -> dip::dfloat
Compute determinant of matrix.
auto Inv() const -> dip::CovarianceMatrix
Compute inverse of matrix.
auto Project(dip::VertexFloat const& v) const -> dip::dfloat
Computes v’ * C * v, with v’ the transpose of v. This is a positive scalar if v is non-zero, because C (this matrix) is positive semidefinite.
auto Eig() const -> dip::CovarianceMatrix::Eigenvalues
Compute eigenvalues of matrix.
auto Ellipse(bool solid = false) const -> dip::CovarianceMatrix::EllipseParameters
Compute parameters of ellipse with same covariance matrix.

Operators

auto operator+=(dip::CovarianceMatrix const& other) -> dip::CovarianceMatrix&
Add other matrix to this matrix.
auto operator*=(dip::dfloat d) -> dip::CovarianceMatrix&
Scale matrix.
auto operator/=(dip::dfloat d) -> dip::CovarianceMatrix&
Scale matrix.

Class documentation

struct EllipseParameters

Container for ellipse parameters.

Variables
dip::dfloat majorAxis Major axis length
dip::dfloat minorAxis Minor axis length
dip::dfloat orientation Orientation of major axis
dip::dfloat eccentricity Ellipse eccentricity

Function documentation

dip::CovarianceMatrix::EllipseParameters Ellipse(bool solid = false) const

Compute parameters of ellipse with same covariance matrix.

If solid is false (default), then it is assumed that the covariance matrix corresponds to an ellipse shell (e.g. obtained through dip::Polygon::CovarianceMatrixVertices). This is the default for backwards-compatibility. If true, the covariance matrix corresponds to a solid ellipse (e.g. obtained though dip::Polygon::CovarianceMatrixSolid).