Hi all,

 

I was using until now Matlab and its about time for me to move to scikit-image as it provide me more flexibility and a lot of benefits.

 

Normally, I used Matlab to calculate the properties of gray-level co-occurrence matrix as shown in this link (http://www.mathworks.co.uk/help/images/ref/graycoprops.html) mainly with this simple script:

 

clc;

 Img = imread('C:\Users\dell\Desktop\ImgTemp\python.jpg');

I=rgb2gray(Img);

% Photo downloaded from “http://i425.photobucket.com/albums/pp337/jewarmy/python.jpg”

GLCM2 = graycomatrix(I);

allst = graycoprops(GLCM2,'all');

 

contrastInfo = allst.Contrast;

display(contrastInfo)

energyInfo =  allst.Energy;

display(energyInfo)

homogeneityInfo = allst.Homogeneity;

display(homogeneityInfo)

correlationInfo = allst.Correlation;

display(correlationInfo)

 

With the following output:

contrastInfo =

    0.2516

energyInfo =

    0.1094

homogeneityInfo =

    0.8959

 correlationInfo =

    0.9672

 

 

While I was trying to do it with scikit-image using this script:

 

import numpy as np

from skimage.io import imread

from skimage.feature import greycomatrix, greycoprops

 

image=imread('C:/Users/dell/Desktop/ImgTemp/python.jpg', as_grey=True)

g = greycomatrix(image, [0, 1], [0, np.pi/2], levels=256)

 

contrast = greycoprops(g, 'contrast')

print('contrast is: ',  contrast)

 

energy = greycoprops(g, 'energy')

print('energy is: ',  energy)

 

homogeneity = greycoprops(g, 'homogeneity')

print('homogeneity is: ',  homogeneity)

 

correlation = greycoprops(g, 'correlation')

print('correlation is: ',  correlation)

 

dissimilarity = greycoprops(g, 'dissimilarity')

print('dissimilarity is: ',  dissimilarity)

 

ASM = greycoprops(g, 'ASM')

print('ASM is: ',  ASM)

 

I get these results:

 

contrast is:  [[0 0]

 [0 0]]

energy is:  [[ 40007.37212065  40007.37212065]

 [ 38525.88698525  38017.06358992]]

homogeneity is:  [[ 165440.  165440.]

 [ 165088.  164970.]]

correlation is:  [[ 1.  1.]

 [ 1.  1.]]

dissimilarity is:  [[0 0]

 [0 0]]

ASM is:  [[1600589824 1600589824]

 [1484243968 1445297124]]

 

I do not understand why there are differences and for sure I miss something. Can someone please explain me what is wrong (I am using python 3.2 and scikit-image 0.8.3).

 

Thanks a lot in advance.