title: OpenCV how to get GLCM gray-level co-occurrence matrix
body: <p>I am trying to extract features using GLCM (gray-level co-occurrence matrix (GLCM) from image) in OpenCV.</p>
  
  <p>In matlab we have <code>graycomatrix</code>. 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?</p>
  
  <p>[EDIT]</p>
  
  <p>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?</p>
  
  <pre><code>            char rawdata[4][4] = { {0, 1, 2, 3},
             {1, 1, 2, 3},
             {1, 0, 2, 0},
             {0, 0,0, 3}};
  
             src-&gt;imageData = (char*)(&amp;rawdata);
  
               CvGLCM* glcm;
              glcm = cvCreateGLCM(src, 2, NULL,4, CV_GLCM_OPTIMIZATION_NONE);
              cvCreateGLCMDescriptors(glcm, CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST);
  
             for (int step=0; step&lt;4; step++)
              {
                   printf("%.3f,", cvGetGLCMDescriptor(glcm, step, CV_GLCMDESC_CONTRAST));
                    printf("\n");
              }
  </code></pre>