MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# what is the procedure to determine the GLCM of non-overlapping blocks with the indexing technique?

Asked by pammy on 13 Feb 2013

GLCM means gray-level co-occurence matrix

i've divided the input image into non-overlapping blocks using the indexing technique u told me earlier...

now i want to calculate the GLCM of every block.

what should i do ?

## Products

No products are associated with this question.

Answer by Image Analyst on 13 Feb 2013

Call graycomatrix(). If you want all 8 directions, you have to call it 8 times.

pammy on 15 Feb 2013
``` i=imread('golf.jpg');
i=rgb2gray(i);
glcm=graycomatrix(i);
disp(glcm);```
``` 16   38      10      1      0     0      0      0
36   1809    588    49      5     0      0      0
7    586    4940   1393    62     3      0      0
5    44     1402   22117   584    36     0      0
0    10     57     576     4290   271    6      0
1    9      9      48      244    2644   100    1
0    0      0      2       8      84     5965   69
0    0      0      0       0      2      51     1809```

i just wanted to know why the matrix is always 8x8...

the value 16 in the first row and first column signifies what???

i read the tutorial of GLCM.this takes into account only horizontal pairs? what if i want the glcm of each block?

in my project i want to calculate the texture of each block dats y m asking???

can u plz sir clarify it to me??

Image Analyst on 15 Feb 2013

Like you said, the default is only one direction. But there are 8 directions you can go from out of a pixel, right? So that's why you need to do it 8 times if you want the GLCM for everything. Actually that will count some directions twice, so you really only need to do it 4 times.

That GLCM you have divides the range 0-255 into 16 ranges: 0-15, 16-31,....240-255. So the 16 means there were 16 occurrences of a situation, in the entire image, where a pixel in the 0-15 range was to the right of another pixel in the 0-15 range.

The output is 8 by 8 because for a uint8 image, there are 256 gray levels, and the 'NumLevels' option of graycomatrix uses 8 levels as the default to split it up into 8 intensity ranges like I mentioned before. You can use numlevels=255 if you want.

pammy on 21 Feb 2013

can u plz tell me by writing some piece of code for GLCM as u said in first paragraph...i.e 8 directions

including all 255 levels...

plz sir it help me alot...