how to find glcm of an image in OpenCV or numpy?

user1234567 picture user1234567 · Oct 24, 2013 · Viewed 8.4k times · Source

I have to find texture based features of an image like correlation, energy, homogeneity, and contrast in Python. I am using python-opencv to do other operations, since python-opencv returns image as an numpy array. But I didn't find any good resource to compute GLCM using either opencv or numpy. Also I have to extract feature for d=1 and angle=[0,45,135,90] and then use this feature in svm.

Answer

RAUSHAN RAJ picture RAUSHAN RAJ · Oct 24, 2013

You have to install the following libraries scipy, numpy and skimage.

skimage has a module called skimage.feature which includes skimage.feature.greycomatrix and skimage.feature.greycoprops. Using these we can calculate the greycoimage for ndarray uint8 and also the greco proporties instructions