From the docs, this is what greycoprops
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.
You are getting a 1×4 array of contrast values because you passed 4 angles to graycomatrix
. In order for the GLCM descriptor to be rotation-invariant it is a common practice to average the feature values computed for different angles and the same distance. Have a look at this paper for a more in depth explanation on how to achieve GLCM features that are robust against rotation.
Demo
In [37]: from numpy import pi
In [38]: from skimage import data
In [39]: from skimage.feature.texture import greycomatrix, greycoprops
In [40]: img = data.camera()
In [41]: greycoprops(greycomatrix(img, distances=[1], angles=[0]), 'contrast')
Out[41]: array([[34000139]], dtype=int64)
In [42]: greycoprops(greycomatrix(img, distances=[1, 2], angles=[0]), 'contrast')
Out[42]:
array([[ 34000139],
[109510654]], dtype=int64)
In [43]: greycoprops(greycomatrix(img, distances=[1, 2], angles=[0, pi/4]), 'contrast')
Out[43]:
array([[ 34000139, 53796929],
[109510654, 53796929]], dtype=int64)
In [44]: greycoprops(greycomatrix(img, distances=[1], angles=[0, pi/4, pi/2]), 'contrast')
Out[44]: array([[34000139, 53796929, 20059013]], dtype=int64)