【发布时间】:2023-04-08 23:59:02
【问题描述】:
我正在尝试检测图像中的弯曲传送带。我使用以下代码使用霍夫变换来检测它的边缘
%# load image, and process it
I = imread('ggp\2.jpg');
g = rgb2gray(I);
bw = edge(g,'Canny');
[H,T,R] = hough(bw);
P = houghpeaks(H,500,'threshold',ceil(0.4*max(H(:))));
% I apply houghlines on the grayscale picture, otherwise it doesn't detect
% the straight lines shown in the picture
lines = houghlines(g,T,R,P,'FillGap',5,'MinLength',50);
figure, imshow(g), hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
deltaY = xy(2,2) - xy(1,2);
deltaX = xy(2,1) - xy(1,1);
angle = atan2(deltaY, deltaX) * 180 / pi;
if (angle == 0)
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');
end
end
如图所示,两条直线成功检测到输送机的顶部和底部边缘,但我不知道如何检测它是否弯曲(在图片中它是弯曲的)以及如何计算弯曲度那个。
如下图手动绘制的近似曲线(红色):
我在 matlab 中没有找到用于检测这种平滑曲线的霍夫变换的代码或函数(例如,二次多项式:y= a*x^2)。也欢迎任何其他解决方案。
【问题讨论】:
-
能否提供原图?
-
@Tapio 我在帖子中添加了图片。
-
我不明白您要检测图像中的什么曲线。您能否在图像上手动绘制并突出显示您希望找到的曲线?
-
@Shai 我把它画成红色。
标签: matlab image-processing computer-vision edge-detection hough-transform