Skip to content

Latest commit

 

History

History
158 lines (112 loc) · 7.66 KB

f_glcm.rst

File metadata and controls

158 lines (112 loc) · 7.66 KB

Texture features / GLCM

A Gray Level Co-occurrence Matrix (GLCM) of size N_g \times N_g describes the joint probability function of an image and is defined as \textbf{P}(i,j|\delta,\theta). The (i,j)-th element of this matrix represents the number of times the combination of indices i and j occur in two pixels in the image, that are separated by a distance of \delta pixels along angle \theta. The distance \delta from the center pixel is defined as the distance according to the Euclidean norm. For \delta=1, this results in 2 neighbors for each of 13 angles in 3D (26-connectivity) and for \delta=2 a 98-connectivity (49 unique angles).

As an example, let the following matrix represent a 5x5 ROI image having 5 discrete grey levels:

\textbf{G} = \begin{bmatrix}
1 & 2 & 5 & 2 & 3\\
3 & 2 & 1 & 3 & 1\\
1 & 3 & 5 & 5 & 2\\
1 & 1 & 1 & 1 & 2\\
1 & 2 & 4 & 3 & 5 \end{bmatrix}

For distance \delta = 1 (considering pixels with a distance of 1 pixel from each other) and angle \theta=0^\circ (horizontal plane, i.e. voxels to the left and right of the center voxel), the following symmetrical GLCM is obtained:

\textbf{P} = \begin{bmatrix}
6 & 4 & 3 & 0 & 0\\
4 & 0 & 2 & 1 & 3\\
3 & 2 & 0 & 1 & 2\\
0 & 1 & 1 & 0 & 0\\
0 & 3 & 2 & 0 & 2 \end{bmatrix}

Let:

  • \epsilon be an arbitrarily small positive number (\approx 2.2\times10^{-16})
  • \textbf{P}(i,j) be the co-occurence matrix for an arbitrary \delta and \theta
  • p_{ij} be the normalized co-occurence matrix and equal to \frac{\textbf{P}(i,j)}{\sum{\textbf{P}(i,j)}}
  • N_g be the number of discrete intensity levels in the image
  • p_x(i) = \sum^{N_g}_{j=1}{p_{ij}} be the marginal row probabilities
  • p_y(j) = \sum^{N_g}_{i=1}{p_{ij}} be the marginal column probabilities
  • \mu_x be the mean gray level intensity of p_x and defined as \mu_x = \sum^{N_g}_{i=1}{p_x(i)i}
  • \mu_y be the mean gray level intensity of p_y and defined as \mu_y = \sum^{N_g}_{j=1}{p_y(j)j}
  • \sigma_x be the standard deviation of p_x
  • \sigma_y be the standard deviation of p_y
  • p_{x+y}(k) = \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p_{ij}},\text{ where }i+j=k,\text{ and }k=2,3,\dots,2N_g
  • p_{x-y}(k) = \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p_{ij}},\text{ where }|i-j|=k,\text{ and }k=0,1,\dots,N_g-1
  • HX = -\sum^{N_g}_{i=1}{p_x(i)\log_2\big(p_x(i)+\epsilon\big)} be the entropy of p_x
  • HY = -\sum^{N_g}_{j=1}{p_y(j)\log_2\big(p_y(j)+\epsilon\big)} be the entropy of p_y
  • HXY = -\sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p_{ij}\log_2\big(p_{ij}+\epsilon\big)} be the entropy of p_{ij}
  • HXY1 = -\sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p_{ij}\log_2\big(p_x(i)p_y(j)+\epsilon\big)}
  • HXY2 = -\sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p_x(i)p_y(j)\log_2\big(p_x(i)p_y(j)+\epsilon\big)}

By default, the value of a feature is calculated on the GLCM for each angle separately, after which the mean of these values is returned. If distance weighting is enabled, GLCM matrices are weighted by weighting factor W and then summed and normalised.

The following features are then calculated based on the collocation matrix.

\underset{\mathrm{Nyxus \, code: \, GLCM\_ASM}} {\textup{angular second moment}} =  \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p_{i,j}^2}
\underset{\mathrm{Nyxus \, code: \, GLCM\_ACOR}} {\textup{autocorrelation}} = \sum^{N_g}_{i=1} \sum^{N_g}_{j=1} p(i,j) i j
\underset{\mathrm{Nyxus \, code: \, GLCM\_CLUPROM}} {\textup{cluster prominence}} = \sum^{N_g}_{i=1} \sum^{N_g}_{j=1} (i + j - \mu_x - \mu_y) ^4 p(i,j)
\underset{\mathrm{Nyxus \, code: \, GLCM\_CLUSHADE}} {\textup{cluster shade}} = \sum^{N_g}_{i=1} \sum^{N_g}_{j=1} (i + j - \mu_x - \mu_y) ^3 p(i,j)
\underset{\mathrm{Nyxus \, code: \, GLCM\_CLUTEND}} {\textup{cluster tendency}} = \sum^{N_g}_{i=1} \sum^{N_g}_{j=1} (i + j - \mu_x - \mu_y) ^2 p(i,j)
\underset{\mathrm{Nyxus \, code: \, GLCM\_CONTRAST}} {\textup{contrast}} = \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{(i-j)^2p_{ij}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_CORRELATION}} {\textup{correlation}} = \frac{\sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p_{ij}ij-\mu_x\mu_y}}{\sigma_x(i)\sigma_y(j)}
\underset{\mathrm{Nyxus \, code: \, GLCM\_DIFAVE}} {\textup{difference average}} =\sum_{k=0}^{N_g-1} k\, p_{i-j,k}
\underset{\mathrm{Nyxus \, code: \, GLCM\_DIFENTRO}} {\textup{difference entropy}} = \sum^{N_g-1}_{k=0}{p_{x-y}(k)\log_2\big(p_{x-y}(k)+\epsilon\big)}
\underset{\mathrm{Nyxus \, code: \, GLCM\_DIFVAR}} {\textup{difference variance}} = \sum^{N_g-1}_{k=0}{(k-\mu_d)^2p_{x-y}(k)}

where the difference average \mu_d is

\mu_d = \sum^{N_g-1}_{k=0} kp_{x-y}(k) .
\underset{\mathrm{Nyxus \, code: \, GLCM\_DIS}} {\textup{dissimilarity}} = \sum_{i=1}^{N_g} \sum_{j=1}^{N_g} |i-j|\, p_{ij}
\underset{\mathrm{Nyxus \, code: \, GLCM\_JE}} {\textup{joint entropy}} = - \sum^{N_g}_{i=1} \sum^{N_g}_{j=1} p(i,j) \log_2 ( p(i,j) + \epsilon )
\underset{\mathrm{Nyxus \, code: \, GLCM\_HOM1}} {\textup{homogeneity 1}} = \sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1} \frac{p(i,j)}{1+|i-j|}
\underset{\mathrm{Nyxus \, code: \, GLCM\_HOM2}} {\textup{homogeneity 2}} = \sum^{N_g}_{i=1} \sum^{N_g}_{j=1}{\frac{p(i,j)}{1+|i-j|^2}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_IDM}} {\textup{inverse difference moment}} = \sum^{N_g-1}_{k=0}{\frac{p_{x-y}(k)}{1+k^2}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_IDMN}} {\textup{inverse difference moment normalized}} = \sum^{N_g-1}_{k=0} \frac {p_{x-y}(k)} {1+\frac{k^2}{N_g^2}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_ID}} {\textup{inverse difference}} =\sum_{i=1}^{N_g} \sum_{j=1}^{N_g} \frac{p_{ij}}{1+|i-j|}
\underset{\mathrm{Nyxus \, code: \, GLCM\_IDN}} {\textup{inverse difference normalized}} = \sum^{N_g-1}_{k=0} \frac {p_{x-y}(k)} {1+\frac{k}{N_g}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_INFOMEAS1}} {\textup{informational measure of correlation 1}} = \frac{HXY-HXY1}{\max{HX,HY}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_INFOMEAS2}} {\textup{information measure of correlation 2}} = \sqrt{1-e^{-2(HXY2-HXY)}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_VARIANCE}} {\textup{variance}} = \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{(i-\mu_x)^2p_{ij}}
\underset{\mathrm{Nyxus \, code: \, GLCM\_SUMAVERAGE}} {\textup{sum average}} = \sum^{2N_g}_{k=2} {p_{x+y}(k)k}
\underset{\mathrm{Nyxus \, code: \, GLCM\_SUMVARIANCE}} {\textup{sum variance}} = \sum^{2N_g}_{k=2} {(k-SA)^2p_{x+y}(k)}
\underset{\mathrm{Nyxus \, code: \, GLCM\_SUMENTROPY}} {\textup{sum entropy}} = \sum^{2N_g}_{k=2} {p_{x+y}(k)\log_2\big(p_{x+y}(k)+\epsilon\big)}
\underset{\mathrm{Nyxus \, code: \, GLCM\_JAVE}} {\textup{joint average}} = \sum_{i=1}^{N_g} \sum_{j=1}^{N_g} i\, p_{ij}
\underset{\mathrm{Nyxus \, code: \, GLCM\_JE}} {\textup{joint entropy}} = -\sum_{i=1}^{N_g} \sum_{j=1}^{N_g} p_{ij} \log_2 p_{ij}
\underset{\mathrm{Nyxus \, code: \, GLCM\_JMAX}} {\textup{joint maximum}} = \text{max}(p_{ij})
\underset{\mathrm{Nyxus \, code: \, GLCM\_JVAR}} {\textup{joint variance}} = \sum_{i=1}^{N_g} \sum_{j=1}^{N_g} \left(i-\mu\right)^2 p_{ij}

References

Haralick, R., Shanmugan, K., Dinstein, I; Textural features for image classification; IEEE Transactions on Systems, Man and Cybernetics; 1973(3), p610-621