• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Matlab实现 霍夫变换直线检测

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

霍夫变换实现直线检测——MATLAB

网上好多不能用,就重新写了一个:


% 入口图像为 BW,出口图像为fclc,closeBW=imread('D:\picture\9dafa605d53eea243812bb29.jpg');BW=rgb2gray(BW);thresh=[0.01,0.17];sigma=2;%定义高斯参数f = edge(double(BW),'canny',thresh,sigma);figure(1),imshow(f,[]);title('canny 边缘检测');[H, theta, rho]= hough(f, 0.5);%imshow(theta,rho,H,[],'notruesize'),axis on,axis normal%xlabel('\theta'),ylabel('rho');[r,c]=houghpeaks(H,5);hold onlines=houghlines(f,theta,rho,r,c);figure,imshow(f,[]),title('Hough Transform Detect Result'),hold onfor k=1:length(lines)     xy=[lines(k).point1;lines(k).point2];plot(xy(:,1),xy(:,2),'LineWidth',4,'Color',[.6 .6 .6]);end



Matlab2012版本的内核函数有所改变,houghpeaks, houghlines等函数有所改变,感谢cuicd2011的提醒,R2012a版本的直线检测稍有变化:

clc,close  BW=imread('D:\picture\9dafa605d53eea243812bb29.jpg');  BW=rgb2gray(BW);  thresh=[0.01,0.17];  sigma=2;%定义高斯参数  f = edge(double(BW),'canny',thresh,sigma);  figure(1),imshow(f,[]);  title('canny 边缘检测');    [H, theta, rho]= hough(f,'RhoResolution', 0.5);  %imshow(theta,rho,H,[],'notruesize'),axis on,axis normal  %xlabel('\theta'),ylabel('rho');    peak=houghpeaks(H,5);  hold on    lines=houghlines(f,theta,rho,peak);  figure,imshow(f,[]),title('Hough Transform Detect Result'),hold on  for k=1:length(lines)      xy=[lines(k).point1;lines(k).point2];      plot(xy(:,1),xy(:,2),'LineWidth',4,'Color',[.6 .6 .6]);  end  



实验结果:




           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap