Three bugs found in GLCM about texture analysis

老外发现的opencv中cvtexture中的三个bug
出处:http://tech.groups.yahoo.com/group/OpenCV/messages/18038?threaded=1&m=e&var=1&tidx=1
Hello everybody,  I ever delivered two articles about GLCM, asking about how to use it(exactly the meaning of the structure member and the meaning of
the function parameters, see 17848).It seems few people are dealing with it and so no one answered me. It is said that you can count on
yourself if no one can be relied on. So I read the whole source code. Fortunately, I have comprehended 90% of them and found 3 bugs
which are listed below. Anyone who is dealing with texture analysis is welcome to get contact with me. We can communicate with each
other. And two heads are always better than one head. Best wishes to everyone~!
In the file “cvtexture.cpp”
(1).In the function “cvCreateGLCM()”,when we allocate memory to the pointer of structure GLCM, “newGLCM”. A mistake was made here.
The original code is:

The right one is:
(2).In the function “icvCreateGLCM_LookupTable_8u_C1R()”,when we allocate memory to one member of structure GLCM, double ***matrices.
Here appears another mistake. They should be replaced by the commentary.


  (3)In the function “icvCreateGLCMDescriptors_AllowDoubleNest()”,the last statement “delete [] marginalProbability;
”should be replaced by “cvFree( (void**)&marginalProbability);” Because the forward statement 
“double*marginalProbability=(double*)cvAlloc(matrixSideLength*sizeof(marginalProbability[0]));”.
Allocation of memory should be coincided with the release of memory.“malloc” with “free”,and “new” with“delete”.
That’s all. Thank you for your attention~!

 

我按照上面所说的修改完三个bug所确实可以运行,但有个严重的问题,那就是内存泄漏,检测一个几分钟的视频内存都被吸光了,机子动不了,只能关机重启。
经过断点排查,原来cvReleaseGLCM函数中还有一个bug,就是
 
应该改为
 
近期使用二值化图像进行提取纹理特征,发现会报错,原来函数icvCreateGLCMDescriptors_AllowDoubleNest有漏洞,修改如下:
原始代码:
 
应该修改为:
 

这样,opencv的纹理检测就完善了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wqvbjhc

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值