[scikit-image] GLCM strange results

Stefanie Lück luecks at gmail.com
Thu Jan 5 09:33:17 EST 2017

Hi everybody,

first of all, a happy to new year!

I am trying to extract GLCM features of my image but I don't understand the
results. The GLCM output images are looking quite different, nevertheless
that the source is quite similar.

I attached three example images and the corresponding GLCM output. I don't
really understand why the second example has much brighter values then the
other two images. Can anybody tell me what I am doing wrong?

Any help would be very appreciated,
thanks in advance,

Here is the code I used:

import cv2
import matplotlib.pyplot as plt

img = cv2.imread(crop_path + image, 0)
glcm_img = np.copy(img)
glcm_img[:] = 0
for i in range(glcm_img.shape[0]):
for j in range(glcm_img.shape[1]):
if i < 3 or j < 3:
if i > (glcm_img.shape[0] - 4) or j > (glcm_img.shape[0] - 4):
glcm_window = img[i - 3: i + 4, j - 3: j + 4]
glcm = greycomatrix(glcm_window, [1], [0], symmetric=True, normed=True)

contrast = greycoprops(glcm, 'dissimilarity')
glcm_img[i, j] = contrast
plt.imsave(glcm_path + image, glcm_img, cmap=plt.cm.gray)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20170105/abe3c24c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glcm.rar
Type: application/rar
Size: 120873 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20170105/abe3c24c/attachment-0001.rar>

More information about the scikit-image mailing list