首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从GLCM中提取Haralick特征。为什么我要为每个特性获得多个值?

从GLCM中提取Haralick特征。为什么我要为每个特性获得多个值?
EN

Stack Overflow用户
提问于 2018-07-14 09:20:04
回答 1查看 3K关注 0票数 3

我昨天看过的报纸。本文以对比度局部均匀性energy为特征,它们都是一个单一的值(据我所知),但根据skimage函数greycomatrix,传递给它们的参数是distancesangles (可以是多个)。

这是我的代码:

代码语言:javascript
复制
import numpy as np
import cv2
from skimage.feature import greycomatrix, greycoprops
from skimage import io, color, img_as_ubyte

img = cv2.imread('Grape___Black_rot28.JPG')
gray_image = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)    

distances = [1, 2, 3]
angles = [0, np.pi/4, np.pi/2, 3*np.pi/4]
glcm = greycomatrix(gray_image, 
                    distances=distances, 
                    angles=angles,
                    symmetric=True,
                    normed=True)

properties = ['contrast', 'energy', 'homogeneity', 'correlation', 'dissimilarity']
contrast = greycoprops(glcm, properties[0])
energy = greycoprops(glcm, properties[1])
homogeneity = greycoprops(glcm, properties[2])
correlation = greycoprops(glcm, properties[3])
dissimilarity = greycoprops(glcm, properties[4])

令我困惑的是,如果我生成一个具有对比度特性的glcm,它将是3x4大小,但根据论文,它是一个单一值,即使我将所有属性的所有3x4值都作为一个特征,我打赌它对于svm模型也会有一个过度拟合的问题。

EN

回答 1

Stack Overflow用户

发布于 2018-07-15 08:32:07

来自graycoproprops文档:

报酬率: 2-D ndarray 自愿性、无偿性结果d,a是d‘’th的属性‘支柱’。 中转税、转轨制、再转轨制、转轨制、转轨制和a角。

您的代码为每个距离角组合生成一个特征值:

代码语言:javascript
复制
In [5]: len(distances)
Out[5]: 3

In [6]: len(angles)
Out[6]: 4

In [7]: contrast.shape
Out[7]: (3, 4)

实现旋转不变性的一个常见做法是沿着angles轴对特征值进行平均化。通过这样做,您将得到与距离相同的特性值:

代码语言:javascript
复制
In [11]: contrast = greycoprops(glcm, properties[0]).mean(axis=1)

In [12]: contrast.shape
Out[12]: (3,)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51337067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档