0

As theory states, a glcm matrix is said to have dimensions of 2^x by 2^x where x is the grayscale depth of the image. My problem is that I get a 8 by 8 matrix instead of a 2^8 By 2^8 matrix when I run it on a 8 bit grayscale image.

Could someone please help me out?

Tonechas
  • 13,398
  • 16
  • 46
  • 80
klijo
  • 15,761
  • 8
  • 34
  • 49

1 Answers1

1

According to MATLAB documentation,

graycomatrix calculates the GLCM from a scaled version of the image. By default, if I is a binary image, graycomatrix scales the image to two gray-levels. If I is an intensity image, graycomatrix scales the image to eight gray-levels. You can specify the number of gray-levels graycomatrix uses to scale the image by using the 'NumLevels' parameter, and the way that graycomatrix scales the values using the 'GrayLimits' parameter — see Parameters.

In short, you need to run the function as follows:

glcm = graycomatrix(I , 'NumLevels' , 2^8 );
Phonon
  • 12,549
  • 13
  • 64
  • 114
  • will such scaling from 256 numlevels to 8 numlevels result in loss in texture information ? – klijo Apr 26 '12 at 15:02
  • That much I cannot tell you. I'm simply going by what the documentation says. Intuitively, you will lose *some* texture content, but from computational point of view there's a trade-off between the number of grayscale levels you're examining and the time your algorithm (whatever you're using this matrix in) will take to process that information. For this reason, it's definitely nice to have that scaling capability. – Phonon Apr 26 '12 at 15:15