python - 通过GLCM从图像中提取纹理特征

标签 python image-processing feature-extraction scikit-image glcm

我使用 GLCM 从图像中获取纹理特征,以便在 knn 和决策树等分类算法中使用它们。当我运行 greycoprops 函数时,它会为每个功能返回一个包含 4 个元素的数组,如下所示。我应该获取要在分类中使用的每个特征的平均值,还是应该如何处理它们?

('Contrast = ', array([[0.88693423, 1.28768135, 1.11643255, 1.7071733 ]]))

最佳答案

来自 docs ,这就是greycoprops返回:

results : 2-D ndarray

2-dimensional array. results[d, a] is the property ‘prop’ for the d’th distance and the a’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/

相关文章:

python - 如何反转列表中给定的 boolean 值?

c++ - 如何合并每个检测到的对象的重叠检测?

c++ - 用于检测人的 Gabor 特征提取

r - 如何根据开始和结束日期将一条记录拆分为多条记录R

matlab - HOG描述符结果的SVM训练(在Matlab中)

python - google appengine 接收电子邮件错误

python - 用字母表中的所有字母更改 python 中单词的第一个字母并生成一个列表

python - 删除列表中的匹配项目

opencv - findContours 寻找 Blob

C# Autolevel 片段?