- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我看过this昨天的纸在本文中,这些特征被视为对比度、局部同质性和能量,它们都是单个值(据我所知)但根据到 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模型会有过拟合的问题。
最佳答案
来自 graycoproprops
文档:
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.
您的代码为每个距离-角度组合生成一个特征值:
In [5]: len(distances)
Out[5]: 3
In [6]: len(angles)
Out[6]: 4
In [7]: contrast.shape
Out[7]: (3, 4)
实现旋转不变性的常见做法是沿角度
轴平均特征值。通过这样做,您将获得与距离一样多的特征值:
In [11]: contrast = greycoprops(glcm, properties[0]).mean(axis=1)
In [12]: contrast.shape
Out[12]: (3,)
关于python - 从 GLCM 中提取 Haralick 特征。为什么我会为每个功能获取多个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51337067/
我想使用 jfeaturelib(基本上是用于 java)计算 android 中的 haralick 功能,但我发现没有ImageIO 或 BufferedImage 在 android 中的实现,
我看过this昨天的纸在本文中,这些特征被视为对比度、局部同质性和能量,它们都是单个值(据我所知)但根据到 skimage 函数 greycomatrix,传递给它们的参数是 distances 和
我是一名优秀的程序员,十分优秀!