基于霍夫变换的直线检测器(Matlab代码实现)

 👨‍🎓个人主页:研学社的博客  

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

  该程序实现了一些基本的图像处理算法,并将它们组合在一起构建了一个基于霍夫变换的直线检测器。该程序能够找到图像中直线段的起点和终点。与大多数视觉算法一样,霍夫变换使用了许多参数,这些参数的最佳值与数据有关(即,一组在一幅图像上非常有效的参数值可能不适合另一幅图像)。通过在测试图像上运行代码和调整参数,它获得了每个图像的最优值,从而获得了良好的性能。

📚2 运行结果

主函数部分代码:

clc;clear;datadir     = '../data';    %the directory containing the imagesresultsdir  = '../results'; %the directory for dumping results%parameterssigma     = 2;threshold = 0.03;rhoRes    = 2;thetaRes  = pi/90;nLines    = 50;%end of parametersimglist = dir(sprintf('%s/*.jpg', datadir));for i = 1:numel(imglist)    %read in images%    [path, imgname, dummy] = fileparts(imglist(i).name);    img = imread(sprintf('%s/%s', datadir, imglist(i).name));if (ndims(img) == 3)        img = rgb2gray(img);    end    img = double(img) / 255;    %actual Hough line code function calls%      [Im Io Ix Iy] = myEdgeFilter(img, sigma);       [H,rhoScale,thetaScale] = myHoughTransform(Im, threshold, rhoRes, thetaRes);    [rhos, thetas] = myHoughLines(H, nLines);    lines = houghlines(Im>threshold, 180*(thetaScale/pi),...        rhoScale, [rhos,thetas],'FillGap',5,'MinLength',10);    %everything below here just saves the outputs to files%    fname = sprintf('%s/%s_01edge.png', resultsdir, imgname);    imwrite(Im/max(Im(:)), fname);    fname = sprintf('%s/%s_02threshold.png', resultsdir, imgname);    imwrite(Im > threshold, fname);    fname = sprintf('%s/%s_03hough.png', resultsdir, imgname);    imwrite(H/max(H(:)), fname);    fname = sprintf('%s/%s_04lines.png', resultsdir, imgname);    img2 = img;for j=1:numel(lines)       img2 = drawLine(img2, lines(j).point1, lines(j).point2);     end         imwrite(img2, fname);end 

🎉3 参考文献

​[1]唐佳林,王镇波,张鑫鑫.基于霍夫变换的直线检测技术[J].科技信息,2011,No.370(14):33+35.

部分理论引用网络文献,若有侵权联系博主删除。

🌈4 Matlab代码实现

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

荔枝科研社

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

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

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

打赏作者

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

抵扣说明:

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

余额充值