我使用 GLCM 从图像中获取纹理特征,以便在 knn 和决策树等分类算法中使用它们。当我运行 greycoprops 函数时,它会为每个功能返回一个包含 4 个元素的数组,如下所示。我应该获取要在分类中使用的每个特征的平均值,还是应该如何处理它们?
('Contrast = ', array([[0.88693423, 1.28768135, 1.11643255, 1.7071733 ]]))
最佳答案
来自 docs ,这就是greycoprops
返回:
results
: 2-D ndarrayblock 引用>2-dimensional array.
results[d, a]
is the property‘prop’
for thed
’th distance and thea
’th angle.您将获得一个 1×4 对比度值数组,因为您将 4 个角度传递给
graycomatrix
。为了使 GLCM 描述符具有旋转不变性,通常的做法是对针对不同角度和相同距离计算的特征值进行平均。看看this paper更深入地解释如何实现对旋转具有鲁棒性的 GLCM 功能。演示
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)
关于python - 通过GLCM从图像中提取纹理特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56188637/