haralickMatrix {EBImage} | R Documentation

## Co-occurrence matrices (GLCM) and Haralick texture features

### Description

A set of functions to compute the co-occurrence matrix (GLCM - gray level co-occurrence matrix) and haralick texture features of objects in an indexed image.

### Usage

      ## S4 method for signature 'IndexedImage, Image':
      haralickMatrix(x, ref, nc = 32, ...)
      ## S4 method for signature 'IndexedImage, Image':
      haralickFeatures(x, ref, nc = 32, ...)

### Arguments

`x` | An object of `IndexedImage` used as a mask.
`ref` | A `Grayscale` object of `Image-class`. The texture is calculated from the data in this image.
`nc` | A numeric value. Specifies the number of gray levels to separate `ref` into when calculating the co-occurrence matrix. Defaults to 32
`...` | Reserved.

### Details

`haralickMatrix` computes a co-occurrence matrix of dimension `nc * nc` for each object in an image. The co-occurrence matrix is constructed by assigning to element `[i,j]` the number of times a pixel of value `i` is adjacent to a pixel of value `j`.

In order to achieve rotational invariance the co-occurrence matrix is computed using four passes through each object. Thus each pixel is compared to four neighbours: right, below, diagonally down left and diagonally down right. In order to achieve symmetry in the co-occurrence matrix the reciprocal of each of these scores is also added. Thus for each pixel we have have a score for comparison with each of the surrounding pixels.

Finally the entire matrix is divided by the total number of comparisons, giving a probability for each of the possible combinations.

`haralickFeatures` computes for each object in an image 12 Haralick texture features, calculated from the co-occurrence matrix. The feature names carry a `t.` prefix (t for texture). The features and their calculations are:

`asm`
  Angular second moment: `sum[_i=1^nc] sum[_j=1^nc]p(i,j)^2`.
`con`
  Contrast: `sum[_i=2^(2*nc)] n^2 * sum[_i=1^nc] sum[_j=1^nc] p(i,j), for all i,j s.t ABS(i - j) = n`.
`cor`
  Correlation of GLCM: `sum[_i=1^nc] sum[_j=1^nc]((i * j) * p(i,j) - mu_x * mu_y) / sigma_x * sigma_y`.
`var`
  Variance: `sum[_i=1^nc] sum[_j=1^nc](i - mu)^2. * p(i,j)`.
`idm`
  Inverse difference moment: `sum[_i=1^nc] sum[_j=1^nc] p(i,j) / (1 + (i - j)^2)` .
`sav`
  Sum average: `sum[_i=2^(2*nc)] i * Px+y(i)`.
`sva`
  Sum variance: `sum[_i=2^(2*nc)] (i - sen)^2 * Px+y(i)`.
`sen`
  Sum entropy: `-sum[_i=2^(2*nc)] Px+y(i) * log( p(i,j) )`.
`ent`
  Entropy: `-sum[_i=1^nc] sum[_j=1^nc] p(i,j) * log( p(i,j) )`.
`dva`
  Difference variance: `sum[_i=0^(nc-1)] (i^2) * Px-y(i)`.
`den`
  Difference entropy: `sum[_i=0^(nc-1)] Px-y(i) * log( Px-y(i,j) )`.
`f12`
  Measure of correlation: `ABS(ent - HXY1) / HX`.
`f13`
  Measure of correlation: `sqrt( 1 - exp( -2 *(HXY2 - ent) ) )`.

Where:

`p(i,j)`
  The value in row i, column j of the co-occurrence matrix.
`Px(i)`
  Partial probability density function. Defined by `sum[_j=1^nc] p(i,j)` .
`Py(j)`
  Partial probability density function. Defined by `sum[_i=1^nc] p(i,j)` .
`mu_x, mu_y`
  Are the means of `Px` and `Px`, the partial probability density functions.
`sigma_x, sigma_y`
  Are the standard deviations of `Px` and `Py`.
`Px+y`
  Is the probability of the co-occurrence matrix co-ordinates summing to `x+y`. It is defined as `Px+y(k) = sum[_i=1^nc] sum[_j=1^nc] p(i,j), i + j = k and k = 2,3,...,2*nc`.
`Px-y`
  Is the probability of the absolute value of the difference between co-occurrence matrix co-ordinates being equal to `x-y`. It is defined as `Px-y(k) = sum[_i=1^nc] sum[_j=1^nc] p(i,j), ABS(i - j) = k and k = 2,3,...,2*nc`.
`HXY1`
  `-sum[_i=1^nc] sum[_j=1^nc] p(i,j) * log( Px(i),Py(j) )` .
`HXY2`
  `-sum[_i=1^nc] sum[_j=1^nc] Px(i)*Py(j) * log( Px(i),Py(j) )` .

### Value

For a single frame in `x` the result of `haralickMatrix` is an array of dimensions `nc` * `nc` * "the number of objects in the frame".
`haralickFeatures` returns a matrix of dimensions "number of objects in the frame" * 12.
For multiple frames a list of each of the above will be returned.

### Author(s)

Mike Smith, msmith@ebi.ac.uk; Oleg Sklyar, osklyar@ebi.ac.uk, 2007

### References

R. M. Haralick, K Shanmugam and Its'Hak Deinstein (1979). Textural Features for Image Classification. IEEE Transactions on Systems, Man and Cybernetics.

### See Also

`IndexedImage, watershed, propagate`

### Examples

      ## see example(getFeatures)

[Package EBImage version 2.2.0 Index]