Hi, I want ask you why the size of graycomatrix 8 x 8 ? that size default 8 x 8 or how ?

1 view (last 30 days)
sir I example matrix gray = [0 1 2 2; 1 1 2 1; 1 0 2 0;]; but after I m=graycomatrix(gray); the result like this :
m =
0 0 0 0 0 0 0 2
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 5

Accepted Answer

Walter Roberson
Walter Roberson on 16 Oct 2018
It is because NumLevels defaults to 8
"Number of gray levels, specified as an integer. For example, if NumLevels is 8, graycomatrix scales the values in I so they are integers between 1 and 8. The number of gray-levels determines the size of the gray-level co-occurrence matrix (glcm)."
  18 Comments
Oman Wisni
Oman Wisni on 22 Oct 2018
Edited: Oman Wisni on 22 Oct 2018
Its okay sir, that formula I got from journal and the theory from haralick. Thanks for answers sir I already get the result and same with graycoprops () :)
sam alsalihy
sam alsalihy on 16 May 2020
it is by defalt the output scale to 8. It ismean that the value of input image will be converted from its range to the range between 0-8 then calculate the glcm matrix
for example if you set image pp=[1 2 5 4 7;5 4 2 5 3; 1 2 3 4 2;2 2 2 3 1 ]
and [GLCMS,SI] = graycomatrix(pp,'NumLevels',7,'G',[]) so the NumLevels=7 it s in the same range ofthe pp image thus will convert matrix SI
1 2 5 4 7
5 4 2 5 3
1 2 3 4 2
2 2 2 3 1
it mean same orginal image. but for example the NumLevels=10 it will convert to range 1-10, thus the SI matrix will be

Sign in to comment.

More Answers (1)

sam alsalihy
sam alsalihy on 16 May 2020
as the following
1 2 7 6 10
7 6 2 7 4
1 2 4 6 2
2 2 2 4 1
then the glcm matrix calculated from SI
1 2 3 4 5 6 7 8 9 10
1: 0 2 0 0 0 0 0 0 0 0
2: 0 2 0 2 0 0 2 0 0 0
3: 0 0 0 0 0 0 0 0 0 0
4: 1 0 0 0 0 1 0 0 0 0
5: 0 0 0 0 0 0 0 0 0 0
6: 0 2 0 0 0 0 0 0 0 1
7: 0 0 0 1 0 2 0 0 0 0
8: 0 0 0 0 0 0 0 0 0 0
9: 0 0 0 0 0 0 0 0 0 0
10: 0 0 0 0 0 0 0 0 0 0

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!