【问题标题】:ValueError buffer source array is read-onlyValueError 缓冲区源数组是只读的
【发布时间】:2020-11-19 12:57:34
【问题描述】:

我正在使用此代码为某个图像提取 GLCM 特征,但它给了我一个值错误

代码:

from PIL import Image
from skimage.feature import greycomatrix, greycoprops
fname = 'trial.jpg'
img = Image.open(fname).convert("L")
img = img.resize((224, 224))
test_glcm = greycomatrix(img, [1], [np.pi/2], 256, symmetric=True, normed=True)

错误:

ValueError 缓冲区源数组是只读的

有谁知道这意味着什么,或者代码中可能存在什么问题?

【问题讨论】:

    标签: python scikit-image glcm


    【解决方案1】:

    要修复错误,您只需将 PIL 图像转换为 NumPy 数组,如下所示:

    test_glcm = greycomatrix(np.array(img), [1], [np.pi/2], 256, symmetric=True, normed=True)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多