我有以下代码,我试图在其中获取与我给定的掩码相对应的图像的一部分。然后我想在该部分应用 skimage.feature.glcm 。但我得到了错误:
glcm = greycomatrix(mancha, [2], [0], levels=None, symmetric = True, normed = True)
File "D:\WinPython-64bit-2.7.13.1ZeroNew\python-2.7.13.amd64\lib\site-packages\skimage\feature\texture.py", line 101, in greycomatrix
assert_nD(image, 2)
File "D:\WinPython-64bit-2.7.13.1ZeroNew\python-2.7.13.amd64\lib\site-packages\skimage\_shared\utils.py", line 178, in assert_nD
raise ValueError(msg_incorrect_dim % (arg_name, '-or-'.join([str(n) for n in ndim])))
ValueError: The parameter `image` must be a 2-dimensional array
代码是:
mask = cv2.imread(pathMask, 0)
cruda = cv2.imread(pathCruda, 0)
imaskc = mask > 0
mancha = cruda[imaskc]
glcm = greycomatrix(mancha, [2], [0], levels=None, symmetric = True, normed = True)
energy = greycoprops(glcm, 'energy')
homogeneity = greycoprops(glcm, 'homogeneity')
我也尝试过不成功:
labeled_image, nb_labels = ndimage.label(mascara)
blobs = ndimage.find_objects(labeled_image)
glcm = greycomatrix(cruda[blobs[0]]
任何想法如何完成这项工作?
谢谢!