Calculate distances to reference Color

In this document the central part of the color distance calculation is explained. The calculation consists of two steps

  1. establish a reference color model

  2. calculating distances to the reference color model

Establishing a reference color model

The standard color distance that is used in CDC, is the Mahalanobis distance [1]. The Mahalanobis distance is a measure of the distance from a point to a multivariate normal distribution.

The multivariate normal distribution is used to describe the distribution of color values from a set of annotated pixels. The multivariate normal distribution is described by the mean value \(\vec{\mu}\) and the covariance matrix \(S\) calculated from the \((R,G,B)\) color values of the sampled pixels. The mean value \(\vec{\mu}\) is a \(<3 \times 1>\) column vector and the covariance matrix is a \(<3 \times 3>\) matrix.

Calculating distance to the color model using Mahalanobis

To calculate the color distance using the Mahalanobis distance, the following equation is used:

\[\sqrt{\left( \vec{x} - \vec{\mu} \right)^T \cdot S^{-1} \cdot \left( \vec{x} - \vec{\mu} \right)}\]

where \(\vec{x}\) is the new color value, \(\vec{\mu}\) the mean color value and \(S\) the covariance matrix.

Calculating distance to the color model using Gaussian Mixture Model

To calculate the color distance using the Gaussian Mixture Model [2], the following equation is used to convert the loglikelihood to a distance:

\[\sqrt{\max\{-\left(L-L_{max}\right),0\}}\]

Where \(L\) is the loglikelihood from the Gaussian Mixture Model and \(L_{max}\) is the maximum loglikelihood of the all the annotated pixels. \(L_{max}\) is used as an approximation of the global maximum of the loglikelihood and the \(\max\) function is to make sure value under the square root cannot be negative. The subtraction of \(L_{max}\) is to achieve a minimum distance close to zero when the values are close to the annotated pixels.

Footnotes