ImageDev

Moments And Orientations

Analysis algorithms measuring features globally to the input image based on moments of inertia and covariance matrices.
These measurements are useful for determining the global characteristics of a shape.

Notice: Some parts of the following information are only relevant for some individual measurements available with the LabelAnalysis algorithm.

First order moments

The first order moments define the centroid or center of mass or barycenter.
In the continuous case they are defined as: $$ M_{1x}=\frac{1}{A(X)}\int_X x \times g(x,y,z) \, dx \, dy \, dz $$ $$ M_{1y}=\frac{1}{A(X)}\int_X y \times g(x,y,z) \, dx \, dy \, dz $$ $$ M_{1z}=\frac{1}{A(X)}\int_X z \times g(x,y,z) \, dx \, dy \, dz $$ and in the discrete case as: $$ M_{1x} = \frac{1}{A(X)}\sum_{X}{x_i \times g(x_i,y_j,z_k)} $$ $$ M_{1y} = \frac{1}{A(X)}\sum_{X}{y_j \times g(x_i,y_j,z_k)} $$ $$ M_{1z} = \frac{1}{A(X)}\sum_{X}{z_k \times g(x_i,y_j,z_k)} $$ where: Notes:

Second order moments

The second order moments are defined in the discrete case as: $$ M_{2x} = \frac{1}{A(X)}\sum_{X}{(x_i-M_{1x})^2 \times g(x_i,y_j,z_k)} $$ $$ M_{2y} = \frac{1}{A(X)}\sum_{X}{(y_i-M_{1y})^2 \times g(x_i,y_j,z_k)} $$ $$ M_{2z} = \frac{1}{A(X)}\sum_{X}{(z_i-M_{1z})^2 \times g(x_i,y_j,z_k)} $$ $$ M_{2xy} = \frac{1}{A(X)}\sum_{X}{(x_i-M_{1x})(y_i-M_{1y}) \times g(x_i,y_j,z_k)} $$ $$ M_{2xz} = \frac{1}{A(X)}\sum_{X}{(x_i-M_{1x})(z_i-M_{1z}) \times g(x_i,y_j,z_k)} $$ $$ M_{2yz} = \frac{1}{A(X)}\sum_{X}{(y_i-M_{1y})(z_i-M_{1z}) \times g(x_i,y_j,z_k)} $$

Variance-covariance matrix

The covariance matrix (or variance-covariance matrix) of a 2D image can be written as: $$ M = \begin{bmatrix} M_{2x} & M_{2xy}\\ M_{2xy} & M_{2y}\end{bmatrix} $$ and for a 3D image: $$ M= \begin{bmatrix} M_{2x} & M_{2xy} & M_{2xz}\\ M_{2xy} & M_{2y} & M_{2yz}\\ M_{2xz} & M_{2yz} & M_{2z}\end{bmatrix} $$

Eigenvalues and eigenvectors

The eigenvalues and eigenvectors are computed by performing a Singular Value Decomposition (SVD) of the covariance matrix.
In an elongated ellipsoid, the largest eigenvalue expresses the longest axis.
In ImageDev, the index convention is:

Orientations

The main orientation of a shape is defined as the direction of its major inertia axis. It is given by the eigenvector of the largest eigenvalue of the covariance matrix.
This is a good measure of orientation for simple and roughly convex objects.

2D orientations

In 2D, the orientation is given by a single value representing the angle between the X axis and the eigenvector. This angle falls between -90 and 90 degrees, considering the positive direction going from the Y-axis to the X-axis. Since ImageDev considers the origin of an image to be in its upper-left corner, the positive direction is visually counterclockwise.



Figure 1. 2D convention for defining an orientation: (left) $\theta_1$ is positive, (right) $\theta_2$ is negative.

3D orientations

In 3D, the orientations are given by the spherical coordinates ($\theta$, $\varphi$), as often used in mathematics (azimuthal angle, $\theta$ and polar angle, $\varphi$). The relation between eigenvector and orientation is given by the following formula: $$V=\begin{bmatrix} v_x\\ v_y\\ v_z\end{bmatrix} = \begin{bmatrix} \sin(\varphi)\cos(\theta)\\ \sin(\varphi)\sin(\theta)\\ \cos(\varphi)\end{bmatrix}$$ This direction can be illustrated on the unit sphere:

<b> Figure 2.</b> Azimuthal and polar angles on the unit sphere
Figure 2. Azimuthal and polar angles on the unit sphere
A secondary orientation is defined as the direction of its minor inertia axis. It is given as the eigenvector of the smallest eigenvalue of the covariance matrix.

Extent values

The extent of the data can be computed in the direction of the largest, medium, and smallest eigenvectors of the covariance matrix.
These values indicate the extents of the bounding box of the shape oriented along the corresponding eigenvector, with respect to the barycenter (maximal extents are positive, minimal extents are negative).

Eccentricity

The eccentricity of a 2D image is defined as: $$E_c(X) = (4\pi)^2\frac{(\lambda_1-\lambda_2)^2}{A^2(X)} = (4\pi)^2\frac{(M_{2x}-M_{2y})^2+4M^2_{2xy}}{A^2(X)}$$ $\lambda_1$ and $\lambda_2$ are the covariance matrix eigenvalues.

A disk or a cross has a null eccentricity as $\lambda_1=\lambda_2$. The eccentricity increases with the difference between the eigenvalues, and thus measures the elongation of the object.
It also indicates in some cases a privileged direction, corresponding to a large eigenvalue and a small one; for instance, $(\lambda_1-\lambda_2)^2$ has a high value, though two orthogonal privileged directions mean two large eigenvalues and a smaller difference $(\lambda_1-\lambda_2)^2$.