0

I am trying to extract features using GLCM (gray-level co-occurrence matrix (GLCM) from image) in OpenCV.

In matlab we have graycomatrix. Does we have any function in openCV for the same purpose? If not, then what is the best solution to achieve it and is there any working example?

[EDIT]

I tried this code but it gives wrong values as compare to matlab result any better solution/function exist in OpenCV or am I doing any mistake in GLCM process?

            char rawdata[4][4] = { {0, 1, 2, 3},
           {1, 1, 2, 3},
           {1, 0, 2, 0},
           {0, 0,0, 3}};

           src->imageData = (char*)(&rawdata);

             CvGLCM* glcm;
            glcm = cvCreateGLCM(src, 2, NULL,4, CV_GLCM_OPTIMIZATION_NONE);
            cvCreateGLCMDescriptors(glcm, CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST);

           for (int step=0; step<4; step++)
            {
                 printf("%.3f,", cvGetGLCMDescriptor(glcm, step, CV_GLCMDESC_CONTRAST));
                  printf("\n");
            }
Tonechas
  • 13,398
  • 16
  • 46
  • 80
wolvorinePk
  • 1,760
  • 5
  • 36
  • 67

2 Answers2

0

There is a class called CvGLCM:

OpenCV-2.3.1a documentation

I have never used it though.

Smash
  • 3,722
  • 4
  • 34
  • 54
  • I used this before but it does not give proper result , any idea why? – wolvorinePk May 01 '12 at 07:05
  • any more help??? its really important for me to solve..i have edit the question with my current code of GLCM but still correct info are not coming. – wolvorinePk May 05 '12 at 11:22
  • can't help you more than this, I only have an older version of opencv installed which doesn't have this package. I suggest you ask another question about the edit part of this question, people will more readily help debugging code than answer theoretical questions – Smash May 08 '12 at 14:56
-1

You have to install scipy,numpy,skimage. and skimage has module skimage.feature which include skimage.feature.greycomatrix and skimage.feature.greycoprops there we can calculate greycoimage for ndarray uint8 and also greco properties instructions

RAUSHAN RAJ
  • 120
  • 2
  • 7