【发布时间】:2016-07-28 21:51:16
【问题描述】:
我正在做一个 matlab 图像处理项目,它基本上从手绘电路图的图像中提取组件和连接。
在预处理得到骨架图像后,我尝试使用霍夫变换来检测线条,以便识别角点和连接路径。
代码如下:
[H,T,R] = hough(im);
peaks = houghpeaks(H,50,'Threshold',ceil(0.3*max(H(:))));
lines = houghlines(im, T,R,peaks, 'Fillgap', 20, 'MinLength', 20);
figure; imshow(im);
title('Lines detected');
hold on;
for l=1:length(lines)
xy = [lines(l).point1; lines(l).point2];
if ((lines(l).theta == 0)||(lines(l).theta >= 355 && lines(l).theta < 5)) || (lines(l).theta < 95 && lines(l).theta > 85) % detect only approx. horizontal and vertical lines
plot(xy(:,1),xy(:,2), 'LineWidth', 2);
end
end
这是我执行时得到的输入和输出:
我需要检测几乎水平或垂直的所有线段,具有最小长度,由于手绘性质而存在一些不规则性。
在给定的屏幕截图中,输出图像仅显示少数检测到的线条,并且部分线条被部分检测到。它实际上应该检测用于连接组件的所有电线
如何调整霍夫变换函数或使用任何其他方法来实现此要求?
【问题讨论】:
标签: matlab image-processing hough-transform image-morphology