0

As we know, GLCM (Grey Level Co-occurrence Matrix) describes the texture characteristics of images. But in usual, the calculation of GLCM in OpenCV, matlab often aim on a picture. But now I just want to get GLCM value of every single point inside the image, but how to get it?

Tonechas
  • 13,398
  • 16
  • 46
  • 80
user909691
  • 25
  • 1
  • 1
  • 8
  • The GLCM is typically defined as a property of the whole image, rather than individual points in the image. What do you mean when you say you want the GLCM value of a point in the image? – Sam Roberts Nov 23 '11 at 09:39
  • I have an image which I would like to extract the GLCM texture in the area of interest(AOI) . but AOI is irregular not a non-rectangular shape. as you say ,so i want to get GLCM values of all the pixel points in the image ,than i will add the values inside the AOI as the final GLCM statistical value of the AOI. – user909691 Nov 24 '11 at 01:10

1 Answers1

1

If I understand your problem correctly, then perhaps you can just set the pixels outside your region of interest to NaN - these pixels are ignored by MATLAB when calculating the GLCM.

For example:

>> im = eye(7)
im =
     1     0     0     0     0     0     0
     0     1     0     0     0     0     0
     0     0     1     0     0     0     0
     0     0     0     1     0     0     0
     0     0     0     0     1     0     0
     0     0     0     0     0     1     0
     0     0     0     0     0     0     1
>> graycomatrix(im)
ans =
    30     0     0     0     0     0     0     6
     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
     6     0     0     0     0     0     0     0
>> im([1:10,13:16,21:24,28:29,34:37,41:49]) = NaN % Remove pixels outside ROI
im =
   NaN   NaN   NaN   NaN   NaN   NaN   NaN
   NaN   NaN   NaN   NaN     0   NaN   NaN
   NaN   NaN     1   NaN     0     0   NaN
   NaN     0     0     1     0     0   NaN
   NaN     0     0     0     1     0   NaN
   NaN   NaN     0     0   NaN   NaN   NaN
   NaN   NaN   NaN   NaN   NaN   NaN   NaN
>> warning('off', 'Images:graycomatrix:scaledImageContainsNan')
>> graycomatrix(im)
ans =
     6     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     0
>> warning('on', 'Images:graycomatrix:scaledImageContainsNan')

Does that do what you need?

Sam Roberts
  • 23,951
  • 1
  • 40
  • 64