小编rpe*_*zoa的帖子

greycomatrix scikit-image python 中的级别参数

我正在使用 scikit-image 工具将 Matlab 图像处理算法转移到 Python,并使用greycomatrix计算灰度共生矩阵 ( GLCM ) 。如果参数小于强度图像的最大值 ( ),我会遇到问题。例如:levelsimage.max()

import numpy as np
from skimage.feature import greycomatrix
image = np.array([[0, 0, 1, 1],[0, 0, 1, 1],[0, 2, 2, 2],[2, 2, 3, 3]], dtype=np.uint8)
result = greycomatrix(image, distances = [1], angles = [0], levels = 4, symmetric=True)
Run Code Online (Sandbox Code Playgroud)

输出是:

glcm = result[:,:,0,0]

array([[4, 2, 1, 0],
   [2, 4, 0, 0],
   [1, 0, 6, 1],
   [0, 0, 1, 2]], dtype=uint32)
Run Code Online (Sandbox Code Playgroud)

这是正确的,4x4 矩阵。但如果levels=3,我无法计算 GLCM,错误是:

result = …
Run Code Online (Sandbox Code Playgroud)

python numpy image-processing scikit-image glcm

5
推荐指数
1
解决办法
6684
查看次数

标签 统计

glcm ×1

image-processing ×1

numpy ×1

python ×1

scikit-image ×1