GLCM in opencv2 (Gray-Level Co-occurrence Matrices)

梦想与她 提交于 2019-12-04 19:51:09

What helped finally was the answer from Alexander Shishkov posted here: link1

I did exchange the texture.cpp code and compiled my opencv-framework again (explained here: link2: i.e. in particular I re-did the last step of the three...).

Doing all that, my glcm-code performs without exception and delivers two numbers per glcm-method.

The legacy function cvCreateGLCM takes the older IplImage* as its input, so you need to convert your cv::Mat image first.

Try this:

// your input image
cv::Mat grayIm = [in_image CVGrayscaleMat];

// create a legacy image
IplImage pGray = grayIm;

// call function
CvGLCM* glcm = cvCreateGLCM(&pGray, 1, NULL, 4, CV_GLCM_OPTIMIZATION_LUT);

I found this when I was looking for GLCM "Implementation of GLCM Haralick Features in openCV", this gets 12 of 14 texture features

https://github.com/Abello966/opencv-haralickfeatures

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!