haralickMatrix {EBImage} | R Documentation |
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.
## S4 method for signature 'IndexedImage, Image': haralickMatrix(x, ref, nc = 32, ...) ## S4 method for signature 'IndexedImage, Image': haralickFeatures(x, ref, nc = 32, ...)
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. |
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
sum[_i=1^nc] sum[_j=1^nc]p(i,j)^2
.con
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
sum[_i=1^nc]
sum[_j=1^nc]((i * j) * p(i,j) - mu_x * mu_y) / sigma_x * sigma_y
.var
sum[_i=1^nc] sum[_j=1^nc](i - mu)^2.
* p(i,j)
.idm
sum[_i=1^nc]
sum[_j=1^nc] p(i,j) / (1 + (i - j)^2)
.sav
sum[_i=2^(2*nc)] i * Px+y(i)
.sva
sum[_i=2^(2*nc)] (i - sen)^2 * Px+y(i)
.sen
-sum[_i=2^(2*nc)] Px+y(i) * log(
p(i,j) )
.ent
-sum[_i=1^nc] sum[_j=1^nc] p(i,j) *
log( p(i,j) )
.dva
sum[_i=0^(nc-1)] (i^2) * Px-y(i)
.den
sum[_i=0^(nc-1)] Px-y(i)
* log( Px-y(i,j) )
.f12
ABS(ent - HXY1) / HX
.f13
sqrt( 1 - exp( -2
*(HXY2 - ent) ) )
.Where:
p(i,j)
Px(i)
sum[_j=1^nc] p(i,j)
.Py(j)
sum[_i=1^nc] p(i,j)
.mu_x, mu_y
Px
and Px
, the partial
probability density functions.sigma_x, sigma_y
Px
and Py
.Px+y
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
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) )
.
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.
Mike Smith, msmith@ebi.ac.uk; Oleg Sklyar, osklyar@ebi.ac.uk, 2007
R. M. Haralick, K Shanmugam and Its'Hak Deinstein (1979). Textural Features for Image Classification. IEEE Transactions on Systems, Man and Cybernetics.
IndexedImage, watershed, propagate
## see example(getFeatures)