skimage2.feature.graycoprops#
- skimage2.feature.graycoprops(P, prop='contrast')[source]#
Calculate texture properties of a GLCM.
Compute a feature of a gray 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]\]
‘mean’: \(\sum_{i=0}^{levels-1} i*P_{i}\)
‘variance’: \(\sum_{i=0}^{levels-1} P_{i}*(i-mean)^2\)
‘std’: \(\sqrt{variance}\)
‘entropy’: \(\sum_{i,j=0}^{levels-1} -P_{i,j}*log(P_{i,j})\)
Each GLCM is normalized to have a sum of 1 before the computation of texture properties.
Changed in version 0.19:
greycopropswas renamed tograycopropsin 0.19.- Parameters:
- Pndarray
Input array.
Pis the gray-level co-occurrence histogram for which to compute the specified property. The valueP[i,j,d,theta]is the number of times that gray-level j occurs at a distance d and at an angle theta from gray-level i.- prop{‘contrast’, ‘dissimilarity’, ‘homogeneity’, ‘energy’, ‘correlation’, ‘ASM’, ‘mean’, ‘variance’, ‘std’, ‘entropy’}, optional
The property of the GLCM to compute. The default is ‘contrast’.
- Returns:
- results2-D ndarray
2-dimensional array.
results[d, a]is the property ‘prop’ for the d’th distance and the a’th angle.
References
[1]M. Hall-Beyer, 2007. GLCM Texture: A Tutorial v. 1.0 through 3.0. The GLCM Tutorial Home Page, https://prism.ucalgary.ca/handle/1880/51900 DOI:
10.11575/PRISM/33280Examples
Compute the contrast for GLCMs with distances [1, 2] and angles [0, pi/2] radians
>>> image = np.array([[0, 0, 1, 1], ... [0, 0, 1, 1], ... [0, 2, 2, 2], ... [2, 2, 3, 3]], dtype=np.uint8) >>> from _skimage2.feature import graycomatrix >>> g = graycomatrix(image, [1, 2], [0, np.pi/2], levels=4, ... normed=True, symmetric=True) >>> contrast = graycoprops(g, 'contrast') >>> contrast array([[0.58333333, 1. ], [1.25 , 2.75 ]])