I have the following code in which I am trying to get a portion of a image corresponding to a mask I am given. Then I would like to apply the skimage.feature.glcm on that portion. But I get the error:
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
The code is:
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')
I have also tried unsuccesfully with:
labeled_image, nb_labels = ndimage.label(mascara)
blobs = ndimage.find_objects(labeled_image)
glcm = greycomatrix(cruda[blobs[0]]
Any ideas how to get this done?
Thanks!