Search code examples
imageimage-processingglcm

Image analysis through GLCM Matrix


I have a image for which I have to calculate the GLCM texture of a selected region. How can I calculate this? I have to calculate the GLCM only for gray area.


Solution

  • To create a Grey-Level Co-occurrence Matrix you simply count how often certain grey Values are Neighbours.

    An Example:

    Image
    1 1 0 2 
    1 2 2 2
    2 2 1 0
    

    Now we define our GLCM as:

    GLCM
         0     1     2
       ------------------
    0 | (0,0) (0,1) (0,2)
      |
    1 | (1,0) (1,1) (1,2)
      |
    2 | (2,0) (2,1) (2,2)
    

    Where (x,y) denotes that how often is the Value y right of the Value x

    For our Example we get:

    GLCM
        0     1     2
       ------------------
    0 | 0     0     1
      |
    1 | 2     1     1
      |
    2 | 0     1     3
    

    You can extend this to get more than only the next neighbour or adjust the direction (North, East, South-East etc.) you look for a neighbour if this gives any benefits to your application. You can even create GLCM for every Pixel direction.

    After that you can achieve a symmetricall GLCM by counting again but interchanging the position of x and y to get (y,x).

    After you have a symmetrical GLCM you can normalize it to get your GLCM Texture.

    There is an excellent Paper from Haralick et.al. that you can read: Textural Features for Image Classification.