greycoprops

greycoprops

skimage.feature.greycoprops(P, prop='contrast') [source]

Calculate texture properties of a GLCM.

Compute a feature of a grey level co-occurrence matrix to serve as a compact summary of the matrix. The properties are computed as follows:

  • ‘contrast’: \sum_{i,j=0}^{levels-1} P_{i,j}(i-j)^2
  • ‘dissimilarity’: \sum_{i,j=0}^{levels-1}P_{i,j}|i-j|
  • ‘homogeneity’: \sum_{i,j=0}^{levels-1}\frac{P_{i,j}}{1+(i-j)^2}
  • ‘ASM’: \sum_{i,j=0}^{levels-1} P_{i,j}^2
  • ‘energy’: \sqrt{ASM}
  • ‘correlation’:

    \sum_{i,j=0}^{levels-1} P_{i,j}\left[\frac{(i-\mu_i) \(j-\mu_j)}{\sqrt{(\sigma_i^2)(\sigma_j^2)}}\right]

Parameters:

P : ndarray

Input array. P is the grey-level co-occurrence histogram for which to compute the specified property. The value P[i,j,d,theta] is the number of times that grey-level j occurs at a distance d and at an angle theta from grey-level i.

prop : {‘contrast’, ‘dissimilarity’, ‘homogeneity’, ‘energy’, ‘correlation’, ‘ASM’}, optional

The property of the GLCM to compute. The default is ‘contrast’.

Returns:

results : 2-D ndarray

2-dimensional array. results[d, a] is the property ‘prop’ for the d’th distance and the a’th angle.

References

[R150] The GLCM Tutorial Home Page, http://www.fp.ucalgary.ca/mhallbey/tutorial.htm

Examples

Compute the contrast for GLCMs with distances [1, 2] and angles [0 degrees, 90 degrees]

>>> image = np.array([[0, 0, 1, 1],
...                   [0, 0, 1, 1],
...                   [0, 2, 2, 2],
...                   [2, 2, 3, 3]], dtype=np.uint8)
>>> g = greycomatrix(image, [1, 2], [0, np.pi/2], levels=4,
...                  normed=True, symmetric=True)
>>> contrast = greycoprops(g, 'contrast')
>>> contrast
array([[ 0.58333333,  1.        ],
       [ 1.25      ,  2.75      ]])
doc_scikit_image
2017-01-12 17:21:10
Comments
Leave a Comment

Please login to continue.