# Facing problem in plotting Grey Level Co-occurrence Matrix (GLCM) of an image in MATLAB [closed]

I am working in the filed of digital image processing. Recently I read a paper that plots Grey Level Co-occurrence Matrix (GLCM) of an image for some processing. As it is shown in following Figure I am trying to plot GLCM in MATLAB using the graycoprops function but not getting expected results.

I am using the following MATLAB code.

img = imread('lena.bmp');
if(size(img, 3) == 3)
img = rgb2gray(img);
end

subplot(1,2,1), imshow(img);
subplot(1,2,1), plot(graycoprops(img));


Kindly tell me that how can I plot GLCM as it is shown in the Figure.

• I am struggling to see the difficulty that seems to have motivated this question, after reviewing MATLAB's help pages on the matter. You are trying to plot a structure, when you should be looking at the output of graycomatrix – A_A Mar 7 '17 at 15:22
• this structure is used to plot the values. It contains four variables that contains few information about the image. I am unable to get the results as it is shown in the paper using the GLCM, – Mayank Tiwari Mar 7 '17 at 15:55

As pointed out by A_A, you need to use the graycomatrix function to get the GLCM:

img = imread('http://www.ux.uis.no/~karlsk/ICTools/lena.bmp');
if(size(img, 3) == 3)
img = rgb2gray(img);
end

subplot(1,2,1), imshow(img);
X = graycomatrix(img, 'NumLevels', 256, 'Symmetric', true);
I = log10(X); I(I==-inf)=nan;
subplot(1,2,2), pcolor(I); shading flat; colormap hsv; axis equal; 