matlab霍夫变换的原点在哪
1个回答
2016-04-25 · 知道合伙人互联网行家
护肤达人IT宅族
知道合伙人互联网行家
向TA提问 私信TA
知道合伙人互联网行家
采纳数:5637
获赞数:17441
毕业于曲阜师范大学,学士学位。互联网行业2年从业经验,读过SEO相关书籍。现任爱家网SEO优化专员。
向TA提问 私信TA
关注
展开全部
本代码提供了matlab下求取经过霍夫变换的直线斜率,并将其联合,代码见下方,实验结果见文末。
% 入口图像为 BW,出口图像为f
%optimize from main_optimize, merely select 2 lines, one has positive
%slope,the other has negative slope
clear all,close all
BW=imread('D:\Images\NEW\img4b9faef664e03.jpg');
figure,imshow(BW);
BW=rgb2gray(BW);
%thresh=[0.01,0.17];
thresh=[0.01,0.10];
sigma=2;%定义高斯参数
f = edge(double(BW),'canny',thresh,sigma);
figure,subplot(121);
imshow(f,[]);
title('canny Edge Detect Result');
[H, theta, rho]= hough(f, 0.1);%cos(theta)*x+sin(theta)*y=rho
%imshow(theta,rho,H,[],'notruesize'),axis on,axis normal
%xlabel('\theta'),ylabel('rho');
[r,c]=houghpeaks(H,10);
hold on
lines=houghlines(f,theta,rho,r,c);
subplot(122);
imshow(f,[]),title('Hough Transform Detect Result'),hold on
nlind=0;%new line index
st=1;
%%%%%%%%%求斜率%%%%%%%%%%%%
for k=1:length(lines)
%xy=[lines(k).point1;lines(k).point2];
xielv(k)=(lines(k).point2(1)-lines(k).point1(1))/(lines(k).point2(2)-lines(k).point1(2)+0.0001)
end
%%%%%%%%%将相同斜率的直线连起来%%%%%%%%%%%%
k=1;
while(k<=length(lines))
if(k~=length(lines))
k=k+1;
end
while(abs(xielv(k)-xielv(k-1))<0.0001)
k=k+1;
if(k>length(lines))
break;
end
end
if(abs(xielv(k-1))<0.05||abs(xielv(k-1))>=10)%eliminate horizontal and vertical lines,防治水平线和楼房
% 入口图像为 BW,出口图像为f
%optimize from main_optimize, merely select 2 lines, one has positive
%slope,the other has negative slope
clear all,close all
BW=imread('D:\Images\NEW\img4b9faef664e03.jpg');
figure,imshow(BW);
BW=rgb2gray(BW);
%thresh=[0.01,0.17];
thresh=[0.01,0.10];
sigma=2;%定义高斯参数
f = edge(double(BW),'canny',thresh,sigma);
figure,subplot(121);
imshow(f,[]);
title('canny Edge Detect Result');
[H, theta, rho]= hough(f, 0.1);%cos(theta)*x+sin(theta)*y=rho
%imshow(theta,rho,H,[],'notruesize'),axis on,axis normal
%xlabel('\theta'),ylabel('rho');
[r,c]=houghpeaks(H,10);
hold on
lines=houghlines(f,theta,rho,r,c);
subplot(122);
imshow(f,[]),title('Hough Transform Detect Result'),hold on
nlind=0;%new line index
st=1;
%%%%%%%%%求斜率%%%%%%%%%%%%
for k=1:length(lines)
%xy=[lines(k).point1;lines(k).point2];
xielv(k)=(lines(k).point2(1)-lines(k).point1(1))/(lines(k).point2(2)-lines(k).point1(2)+0.0001)
end
%%%%%%%%%将相同斜率的直线连起来%%%%%%%%%%%%
k=1;
while(k<=length(lines))
if(k~=length(lines))
k=k+1;
end
while(abs(xielv(k)-xielv(k-1))<0.0001)
k=k+1;
if(k>length(lines))
break;
end
end
if(abs(xielv(k-1))<0.05||abs(xielv(k-1))>=10)%eliminate horizontal and vertical lines,防治水平线和楼房
东莞大凡
2024-08-07 广告
2024-08-07 广告
标定板认准大凡光学科技,专业生产研发厂家,专业从事光学影像测量仪,光学投影测量仪.光学三维测量仪,光学二维测量仪,光学二维测量仪,光学三维测量仪,光学二维测量仪.的研发生产销售。东莞市大凡光学科技有限公司创立于 2018 年,公司总部坐落于...
点击进入详情页
本回答由东莞大凡提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询