资源简介
霍夫变换找圆.zip
代码片段和文件信息
function [para] = findcircle(BWstepRstepAngleminRmaxRp)
[mn] = size(BW);% BW:二值图像;
cntR = round((maxR-minR)/stepR)+1;% stepR:检测的圆半径步长, minR:最小圆半径, maxR:最大圆半径
cntAngle = round(2*pi/stepAngle);% stepAngle:角度步长,单位为弧度
hough_space = zeros(mncntR);% hough_space:参数空间,h(abr)表示圆心在(ab)半径为r的圆上的点数
[rowscols] = find(BW);
cntPoints = size(rows1);
% Hough变换将图像空间(xy)对应到参数空间(abr)
% a = x-r*cos(angle) b = y-r*sin(angle)
for i=1:cntPoints
for r=1:cntR
for k=1:cntAngle
a = round(rows(i)-(minR+(r-1)*stepR)*cos(k*stepAngle));
b = round(cols(i)-(minR+(r-1)*stepR)*sin(k*stepAngle));
if(a>0 && a<=m && b>0 && b<=n)
hough_space(abr) = hough_space(abr)+1;
end
end
end
end
% 寻找满足阈值的圆的参数
max_para = max(max(max(hough_space)));
index = find(hough_space>=max_para*p); % p:以p*hough_space的最大值为阈值,p取0,1之间的数
length = size(index1);
hough_circle=zeros(mn);
for i=1:cntPoints
for k=1:length
par3 = floor(index(k)/(m*n))+1;
par2 = floor((index(k)-(par3-1)*(m*n))/m)+1;
par1 = index(k)-(par3-1)*(m*n)-(par2-1)*m;
if((rows(i)-par1)^2+(cols(i)-par2)^2<(minR+(par3-1)*stepR)^2+5 && (rows(i)-par1)^2+(cols(i)-par2)^2>(minR+(par3-1)*stepR)^2-5)
hough_circle(rows(i)cols(i)) = 1;% hough_circl:二值图像,检测到的圆
end
end
end
for k=1:length
par3 = floor(index(k)/(m*n))+1;
par2 = floor((index(k)-(par3-1)*(m*n))/m)+1; % 圆心y坐标
par1 = index(k)-(par3-1)*(m*n)-(par2-1)*m; % 圆心x坐标
par3 = minR+(par3-1)*stepR; % 圆的半径
% fprintf(1‘Center %d %d radius %d\n‘par1par2par3);
para(k:) = [par1par2par3]; % para:检测到的圆的圆心、半径
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 37906 2016-04-26 14:30 coins.png
文件 1879 2016-04-26 15:15 findcircle.m
文件 1338 2016-04-26 15:30 main.m
文件 397455 2016-04-26 14:30 pillsetc.png
文件 284401 2016-04-26 14:30 tape.png
- 上一篇:校园导航系统.rar
- 下一篇:shuiguopeidui.aia
相关资源
- shuiguopeidui.aia
- 校园导航系统.rar
- fn_check_creditCode.rar
- -Lyapunov指数的计算方法.doc
- ADC0809.rar
- UBOOTloadb命令加载应用程序到SDRAM中运
- 华为设备-eNSP配置说明.doc
- haarcascade_mcs_mouth2019.rar
- 国家互联网安全中心面试准备材料.
- EV_RWD_2NEW.rar
- CORBA开源测试工具.pdf
- 登陆界面二2012-12-25.rar
- 区块链开发入门到精通全套视频.txt
- FZ4与三菱PLC通讯总结.docx
- 997783QTableWidget表头添加复选框.zip
- 4c0138bbb96b33332ad8287cd800de13.zip
- 2018机器学习试题.doc
- PatentDocuments.rar
- GOLAY.c
- WCD9335.pdf
- PDLED8Test.exe
- 91605.pdf
- c6viqw.doc
- AD库百度云.txt
- 64位.zip
- jm电子琴.doc
- sharedmatting.rar
- SPH算法k文件.rar
- .C.rar
- music.zip
评论
共有 条评论