OpenCV如何获取GLCM灰度共现矩阵 [英] OpenCV how to get GLCM gray-level co-occurrence matrix

查看:656
本文介绍了OpenCV如何获取GLCM灰度共现矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在OpenCV中使用GLCM(图像中的灰度级共现矩阵(GLCM))提取特征.

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

在matlab中,我们有graycomatrix.在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?

我尝试了这段代码,但是与matlab结果相比,它给出了错误的值,或者OpenCV中存在更好的解决方案/功能,或者我在GLCM过程中犯了任何错误?

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");
            }

推荐答案

有一个名为CvGLCM的类:

There is a class called CvGLCM:

OpenCV-2.3.1a文档

我从没用过它.

这篇关于OpenCV如何获取GLCM灰度共现矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆