熵提取后的图像怎么提取特征点

千羽QY 2019-03-03 03:23:30
我在做动态检测,有一步是根据熵值排序取中间一半,提取之后是有黑块的图像,不作处理直接提取特征点的话会有很大干扰,请问有什么方法消除影响吗?万分感谢
...全文
122 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
千羽QY 2019-03-06
  • 打赏
  • 举报
回复
引用 1 楼 qq_33331530 的回复:
最近也在学习,您的图像熵的代码可以分享吗?

//计算图像熵
double motionDetect::calcEntropy(Mat &img)
{
int width = img.cols;
int height = img.rows;
//计算每个灰度像素的占比
int count[256] = { 0 }; //每个像素的个数
double ratio[256] = { 0.0 }; //每个像素的占比
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
int pixelVal = static_cast<int>(img.at<uchar>(row, col));
count[pixelVal]++;
}
}
for (int i = 0; i < 256; i++)
{
ratio[i] = count[i] * 1.0 / (width*height*1.0);
}
//计算熵
double val[256] = { 0.0 };
double entropy = 0.0;
for (int i = 0; i < 256; i++)
{
//f * log2 f
//log2 f = log(f)/log(2);
if (ratio[i] == 0) {
val[i] = 0;
}
else {
val[i] = ratio[i] * log(ratio[i]) / log(2);

}
entropy -= val[i];
}
return entropy;
}
ycl吾爱有仨 2019-03-05
  • 打赏
  • 举报
回复
最近也在学习,您的图像熵的代码可以分享吗?

4,248

社区成员

发帖
与我相关
我的任务
社区描述
OpenCV相关技术交流专区
计算机视觉人工智能opencv 技术论坛(原bbs) 广东省·深圳市
社区管理员
  • OpenCV
  • 幻灰龙
  • OpenCV中国团队
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

OpenCV中国团队官方博客:https://blog.csdn.net/opencvchina

试试用AI创作助手写篇文章吧