- 浏览: 425804 次
- 性别:
- 来自: 杭州
-
文章分类
最新评论
-
Iuranus:
“查询文本的64位simhash code的所有3位以内变化的 ...
我的数学之美系列二 —— simhash与重复信息识别 -
夜的那种黑丶:
博主,请教一个问题,我利用OpenCV3提取得到SIFT特征, ...
JAVA实现的Locality Sensitive Hash -
夜的那种黑丶:
最近要用到这方面的内容,楼主贴出的代码少了一些工具类吧,求一份 ...
JAVA实现的Locality Sensitive Hash -
wang_zhao:
博主您好 ,能否求一份该博文对应源码,在下学生狗一枚,非常感谢 ...
JAVA实现的Locality Sensitive Hash -
qwertykln:
博主,能不能发一份完整代码给我啊,我现在正在学习这个,邮箱:3 ...
JAVA实现的Locality Sensitive Hash
方向梯度直方图(Histograms of Oriented Gradients,简称HOG特征)结合支持向量机( support vector machine, 简称SVM),被广泛应用于图像识别中,尤其在行人检测中获得了极大的成功。
积分直方图可以用于快速计算原始图像矩形区域内的HOG特征。积分直方图的概念类似与viola和jones在脸部识别中所用的积分图像。
下面的代码给出了,对于一幅给定的图像,如何快速计算积分直方图,以及如何使用其进行HOG特征的演算(关键处以给出注释):
如何使用上面的函数来计算9维的方向梯度直方图呢?如下:
积分直方图可以用于快速计算原始图像矩形区域内的HOG特征。积分直方图的概念类似与viola和jones在脸部识别中所用的积分图像。
下面的代码给出了,对于一幅给定的图像,如何快速计算积分直方图,以及如何使用其进行HOG特征的演算(关键处以给出注释):
/*Function to calculate the integral histogram*/ IplImage** calculateIntegralHOG(IplImage* in) { /*Convert the input image to grayscale*/ IplImage* img_gray = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U,1); cvCvtColor(in, img_gray, CV_BGR2GRAY); cvEqualizeHist(img_gray,img_gray); /*Calculate the derivates of the grayscale image in the x and y directions using a sobel operator and obtain 2 gradient images for the x and y directions*/ IplImage *xsobel, *ysobel; xsobel = doSobel(img_gray, 1, 0, 3); ysobel = doSobel(img_gray, 0, 1, 3); cvReleaseImage(&img_gray); /* Create an array of 9 images (9 because I assume bin size 20 degrees and unsigned gradient ( 180/20 = 9), one for each bin which will have zeroes for all pixels, except for the pixels in the original image for which the gradient values correspond to the particular bin. These will be referred to as bin images. These bin images will be then used to calculate the integral histogram, which will quicken the calculation of HOG descriptors */ IplImage** bins = (IplImage**) malloc(9 * sizeof(IplImage*)); for (int i = 0; i < 9 ; i++) { bins[i] = cvCreateImage(cvGetSize(in), IPL_DEPTH_32F,1); cvSetZero(bins); } /* Create an array of 9 images ( note the dimensions of the image, the cvIntegral() function requires the size to be that), to store the integral images calculated from the above bin images. These 9 integral images together constitute the integral histogram */ IplImage** integrals = (IplImage**) malloc(9 * sizeof(IplImage*)); for (int i = 0; i < 9 ; i++) { integrals[i] = cvCreateImage(cvSize(in->width + 1, in->height + 1), IPL_DEPTH_64F,1); } /* Calculate the bin images. The magnitude and orientation of the gradient at each pixel is calculated using the xsobel and ysobel images.{Magnitude = sqrt(sq(xsobel) + sq(ysobel) ), gradient = itan (ysobel/xsobel) }. Then according to the orientation of the gradient, the value of the corresponding pixel in the corresponding image is set */ int x, y; float temp_gradient, temp_magnitude; for (y = 0; y < in->height; y++) { /* ptr1 and ptr2 point to beginning of the current row in the xsobel and ysobel images respectively. ptrs point to the beginning of the current rows in the bin images */ float* ptr1 = (float*) (xsobel->imageData + y * (xsobel->widthStep)); float* ptr2 = (float*) (ysobel->imageData + y * (ysobel->widthStep)); float** ptrs = (float**) malloc(9 * sizeof(float*)); for (int i = 0; i < 9 ;i++){ ptrs[i] = (float*) (bins[i]->imageData + y * (bins->widthStep)); } /*For every pixel in a row gradient orientation and magnitude are calculated and corresponding values set for the bin images. */ for (x = 0; x <in->width; x++) { /* if the xsobel derivative is zero for a pixel, a small value is added to it, to avoid division by zero. atan returns values in radians, which on being converted to degrees, correspond to values between -90 and 90 degrees. 90 is added to each orientation, to shift the orientation values range from {-90-90} to {0-180}. This is just a matter of convention. {-90-90} values can also be used for the calculation. */ if (ptr1[x] == 0){ temp_gradient = ((atan(ptr2[x] / (ptr1[x] + 0.00001))) * (180/ PI)) + 90; } else{ temp_gradient = ((atan(ptr2[x] / ptr1[x])) * (180 / PI)) + 90; } temp_magnitude = sqrt((ptr1[x] * ptr1[x]) + (ptr2[x] * ptr2[x])); /*The bin image is selected according to the gradient values. The corresponding pixel value is made equal to the gradient magnitude at that pixel in the corresponding bin image */ if (temp_gradient <= 20) { ptrs[0][x] = temp_magnitude; } else if (temp_gradient <= 40) { ptrs[1][x] = temp_magnitude; } else if (temp_gradient <= 60) { ptrs[2][x] = temp_magnitude; } else if (temp_gradient <= 80) { ptrs[3][x] = temp_magnitude; } else if (temp_gradient <= 100) { ptrs[4][x] = temp_magnitude; } else if (temp_gradient <= 120) { ptrs[5][x] = temp_magnitude; } else if (temp_gradient <= 140) { ptrs[6][x] = temp_magnitude; } else if (temp_gradient <= 160) { ptrs[7][x] = temp_magnitude; } else { ptrs[8][x] = temp_magnitude; } } } cvReleaseImage(&xsobel); cvReleaseImage(&ysobel); /*Integral images for each of the bin images are calculated*/ for (int i = 0; i <9 ; i++){ cvIntegral(bins[i], integrals[i]); } for (int i = 0; i <9 ; i++){ cvReleaseImage(&bins[i]); } /*The function returns an array of 9 images which consitute the integral histogram*/ return (integrals); }
如何使用上面的函数来计算9维的方向梯度直方图呢?如下:
/* The following function takes as input the rectangular cell for which the histogram of oriented gradients has to be calculated, a matrix hog_cell of dimensions 1x9 to store the bin values for the histogram, the integral histogram, and the normalization scheme to be used. No normalization is done if normalization = -1 */ void calculateHOG_rect(CvRect cell, CvMat* hog_cell, IplImage** integrals, int normalization) { /* Calculate the bin values for each of the bin of the histogram one by one */ for (int i = 0; i < 9 ; i++){ float a =((double*)(integrals[i]->imageData + (cell.y) * (integrals-> widthStep)))[cell.x]; float b = ((double*) (integrals->imageData + (cell.y + cell.height) * (integrals->widthStep)))[cell.x + cell.width]; float c = ((double*) (integrals->imageData + (cell.y) * (integrals- >widthStep)))[cell.x + cell.width]; float d = ((double*) (integrals->imageData + (cell.y + cell.height) * (integrals->widthStep)))[cell.x]; ((float*) hog_cell->data.fl) = (a + b) - (c + d); } /*Normalize the matrix*/ if (normalization != -1){ cvNormalize(hog_cell, hog_cell, 1, 0, normalization); } }
发表评论
-
使用opencv作物件识别(三) —— 训练数据
2011-04-26 15:50 0对于前面所计算得到的HOG特征,我们采用现在比较流行的SVM来 ... -
使用opencv作物件识别(二) —— HOG特征的计算
2011-04-25 14:54 0关于HOG检测中的一些名词解释,参考下面的说明: ... -
【翻译】Seeing With OpenCV - Part 1: Introduction to OpenCV
2011-04-19 14:24 4883本文翻译自Robin Hewitt的 ... -
我的数学之美(三) —— 使用支持向量机进行预测
2011-04-09 18:20 8214现实生活中充满着预测问题,即对未知世界的大胆猜测。我们基于什么 ... -
一个运用SVM进行回归的例子
2011-04-08 11:29 7877#include "cv.h" #inc ... -
黄色-图片识别引擎
2011-04-04 16:45 7060黄色-图片自动识别是一 ... -
黄色-图片识别引擎的一些心得
2011-04-02 17:49 9399黄色-图片自动识别是一个涉及到图像处理、模式识别、机器学习、统 ... -
使用标签云扩展自己的应用
2011-03-23 21:50 1642标签云或文字云是关键词的视觉化描述,用于汇总用户生成的标签或一 ... -
Pascal VOC Challenge —— 图像识别与物件分类的挑战
2011-03-22 13:35 27262在计算视觉的领域中,Pascal VOC Challenge ... -
我的数学之美(一)——RANSAC算法详解
2011-03-14 12:53 102014给定两个点p1与p2的坐标 ... -
JAVA实现的Locality Sensitive Hash
2011-03-07 11:36 8587我在之前的博客已大致介绍了LSH的原理及其的适用场景,有兴趣的 ... -
漫谈计算机视觉
2011-02-22 17:27 2929从输入图象到信息获取之间存在着巨大的认知空白,其间需要经过一系 ... -
Standard Kmean Cluster的实现[Java]
2011-02-17 13:56 5627Kmean Cluster是一种机器学习中常用的无监督分析方法 ... -
使用tesseract-ocr破解网站验证码
2011-02-12 10:24 41830首先我得承认,关注tesseract-ocr, 是冲着下面这篇 ... -
利用贝叶斯制定反垃圾邮件策略
2011-02-12 09:48 0目前,我正在将词袋模型应用于机器视觉&物体识别,这个会 ... -
视觉特征抽取算法——SURF
2010-12-27 13:34 5011目前公司PF系统(违禁图片机器审核)运营尚存在一些问题,主要包 ... -
基于统计概率和机器学习的文本分类技术 —— 社区产品机器审核机制预研报告
2010-12-01 14:03 3090基于统计概率和机器学 ... -
互联网相似图像识别检索引擎 —— 基于图像签名的方式
2010-11-29 14:06 9770一、引言 多媒体识别 ...
相关推荐
OpenCV提供了多种特征提取方法,如SIFT(尺度不变特征转换)、SURF(加速稳健特征)和HOG(方向梯度直方图)等,这些方法可以用于识别害虫的独特特征。 3. 分割技术:通过图像分割,可以将害虫与背景分离,常见的...
SIFT(尺度不变特征转换)、SURF(加速稳健特征)、HOG(方向梯度直方图)等是常用的特征提取方法,它们能够在不同尺度、旋转下保持稳定,便于物体识别和匹配。 四、深度学习与卷积神经网络 近年来,深度学习尤其是...
3. 目标检测:可能使用经典的Haar级联分类器、HOG+SVM或现代的深度学习模型如YOLO、SSD等,来识别农田、作物或其他重要目标。 4. 图像分割:可能采用了阈值分割、区域生长、彩色空间转换等方法,将目标对象与背景...
在本项目中,我们可能使用OpenCV库,它提供了丰富的函数用于图像读取、预处理(如灰度化、直方图均衡化)、特征提取和图像变换等。 接着,病虫害检测的关键在于特征识别。这可能涉及到边缘检测(如Canny算法)、...
内容概要:本文详细介绍了如何利用Matlab构建、优化和应用决策分类树。首先,讲解了数据准备阶段,将数据与程序分离,确保灵活性。接着,通过具体实例展示了如何使用Matlab内置函数如fitctree快速构建决策树模型,并通过可视化工具直观呈现决策树结构。针对可能出现的过拟合问题,提出了基于成本复杂度的剪枝方法,以提高模型的泛化能力。此外,还分享了一些实用技巧,如处理连续特征、保存模型、并行计算等,帮助用户更好地理解和应用决策树。 适合人群:具有一定编程基础的数据分析师、机器学习爱好者及科研工作者。 使用场景及目标:适用于需要进行数据分类任务的场景,特别是当需要解释性强的模型时。主要目标是教会读者如何在Matlab环境中高效地构建和优化决策分类树,从而应用于实际项目中。 其他说明:文中不仅提供了完整的代码示例,还强调了代码模块化的重要性,便于后续维护和扩展。同时,对于初学者来说,建议从简单的鸢尾花数据集开始练习,逐步掌握决策树的各项技能。
《营销调研》第7章-探索性调研数据采集.pptx
Assignment1_search_final(1).ipynb
美团优惠券小程序带举牌小人带菜谱+流量主模式,挺多外卖小程序的,但是都没有搭建教程 搭建: 1、下载源码,去微信公众平台注册自己的账号 2、解压到桌面 3、打开微信开发者工具添加小程序-把解压的源码添加进去-appid改成自己小程序的 4、在pages/index/index.js文件搜流量主广告改成自己的广告ID 5、到微信公众平台登陆自己的小程序-开发管理-开发设置-服务器域名修改成
《计算机录入技术》第十八章-常用外文输入法.pptx
基于Andorid的跨屏拖动应用设计实现源码,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。
《网站建设与维护》项目4-在线购物商城用户管理功能.pptx
区块链_房屋转租系统_去中心化存储_数据防篡改_智能合约_S_1744435730
《计算机应用基础实训指导》实训五-Word-2010的文字编辑操作.pptx
《移动通信(第4版)》第5章-组网技术.ppt
ABB机器人基础.pdf
《综合布线施工技术》第9章-综合布线实训指导.ppt
很不错的一套站群系统源码,后台配置采集节点,输入目标站地址即可全自动智能转换自动全站采集!支持 https、支持 POST 获取、支持搜索、支持 cookie、支持代理、支持破解防盗链、支持破解防采集 全自动分析,内外链接自动转换、图片地址、css、js,自动分析 CSS 内的图片使得页面风格不丢失: 广告标签,方便在规则里直接替换广告代码 支持自定义标签,标签可自定义内容、自由截取、内容正则截取。可以放在模板里,也可以在规则里替换 支持自定义模板,可使用标签 diy 个性模板,真正做到内容上移花接木 调试模式,可观察采集性能,便于发现和解决各种错误 多条采集规则一键切换,支持导入导出 内置强大替换和过滤功能,标签过滤、站内外过滤、字符串替换、等等 IP 屏蔽功能,屏蔽想要屏蔽 IP 地址让它无法访问 ****高级功能*****· url 过滤功能,可过滤屏蔽不采集指定链接· 伪原创,近义词替换有利于 seo· 伪静态,url 伪静态化,有利于 seo· 自动缓存自动更新,可设置缓存时间达到自动更新,css 缓存· 支持演示有阿三源码简繁体互转· 代理 IP、伪造 IP、随机 IP、伪造 user-agent、伪造 referer 来路、自定义 cookie,以便应对防采集措施· url 地址加密转换,个性化 url,让你的 url 地址与众不同· 关键词内链功能· 还有更多功能等你发现…… 程序使用非常简单,仅需在后台输入一个域名即可建站,不限子域名,站群利器,无授权,无绑定限制,使用后台功能可对页面进行自定义修改,在程序后台开启生 成功能,只要访问页面就会生成一个本地文件。当用户再次访问的时候就直接访问网站本地的页面,所以目标站点无法访问了也没关系,我们的站点依然可以访问, 支持伪静态、伪原创、生成静态文件、自定义替换、广告管理、友情链接管理、自动下载 CSS 内的图。
【自然语言处理】文本分类方法综述:从基础模型到深度学习的情感分析系统设计
基于Andorid的下拉浏览应用设计实现源码,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。
内容概要:本文详细介绍了一个原创的P2插电式混合动力系统Simulink模型,该模型基于逻辑门限值控制策略,涵盖了多个关键模块如工况输入、驾驶员模型、发动机模型、电机模型、制动能量回收模型、转矩分配模型、运行模式切换模型、档位切换模型以及纵向动力学模型。模型支持多种标准工况(WLTC、UDDS、EUDC、NEDC)和自定义工况,并展示了丰富的仿真结果,包括发动机和电机转矩变化、工作模式切换、档位变化、电池SOC变化、燃油消耗量、速度跟随和最大爬坡度等。此外,文章还深入探讨了逻辑门限值控制策略的具体实现及其效果,提供了详细的代码示例和技术细节。 适合人群:汽车工程专业学生、研究人员、混动汽车开发者及爱好者。 使用场景及目标:①用于教学和科研,帮助理解和掌握P2混动系统的原理和控制策略;②作为开发工具,辅助设计和优化混动汽车控制系统;③提供仿真平台,评估不同工况下的混动系统性能。 其他说明:文中不仅介绍了模型的整体架构和各模块的功能,还分享了许多实用的调试技巧和优化方法,使读者能够更好地理解和应用该模型。