如何用最小二乘法或HOUGH变换检测出下图中的4条直线,并求出其交点。求matlab代码。 200
4个回答
展开全部
Search for line segments in an image
I = imread('circuit.tif');
rotI = imrotate(I,33,'crop');
BW = edge(rotI,'canny');
[H,T,R] = hough(BW);
imshow(H,[],'XData',T,'YData',R,...
'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
plot(x,y,'s','color','white');
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
figure, imshow(rotI), hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines 交点
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
I = imread('circuit.tif');
rotI = imrotate(I,33,'crop');
BW = edge(rotI,'canny');
[H,T,R] = hough(BW);
imshow(H,[],'XData',T,'YData',R,...
'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
plot(x,y,'s','color','white');
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
figure, imshow(rotI), hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines 交点
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
追问
这个是HOUGH 变换 检测直线···我尝试过··检测不出来··别的图像可以··这幅不行····
追答
bwmorph -
Morphological operations on binary images
Syntax
BW2 = bwmorph(BW,operation)
BW2 = bwmorph(BW,operation,n)
Description
BW2 = bwmorph(BW,operation) applies a specific morphological operation to the binary image BW.
BW2 = bwmorph(BW,operation,n) applies the operation n times. n can be Inf, in which case the operation is repeated until the image no longer changes.
operation=endpoints
----------------------------------------------
http://www.cs.sfu.ca/~hamarneh/ecopy/compvis1999_hough.pdf
http://www.cs.uregina.ca/Links/class-info/425/Lab4/index.html
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
富港检测东莞有限公司
2024-12-24 广告
2024-12-24 广告
正弦振动多用于找出产品设计或包装设计的脆弱点。看在哪一个具体频率点响应最大(共振点);富港工业检测技术有限公司是一家专业的第三方检测机构,拥有完善的质量管理体系,先进的检测设备,优秀的技术人才;已取得CNAS、CMA、ISTA等资质认可,包...
点击进入详情页
本回答由富港检测东莞有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询