我昨天看过这的报纸。本文以对比度、局部均匀性和energy为特征,它们都是一个单一的值(据我所知),但根据skimage函数greycomatrix,传递给它们的参数是distances和angles (可以是多个)。
这是我的代码:
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模型也会有一个过度拟合的问题。
发布于 2018-07-15 08:32:07
来自graycoproprops文档:
报酬率: 2-D ndarray 自愿性、无偿性结果d,a是d‘’th的属性‘支柱’。 中转税、转轨制、再转轨制、转轨制、转轨制和a角。
您的代码为每个距离角组合生成一个特征值:
In [5]: len(distances)
Out[5]: 3
In [6]: len(angles)
Out[6]: 4
In [7]: contrast.shape
Out[7]: (3, 4)实现旋转不变性的一个常见做法是沿着angles轴对特征值进行平均化。通过这样做,您将得到与距离相同的特性值:
In [11]: contrast = greycoprops(glcm, properties[0]).mean(axis=1)
In [12]: contrast.shape
Out[12]: (3,)https://stackoverflow.com/questions/51337067
复制相似问题