我试图检测图像中的弯曲输送机.我使用以下代码使用Hough变换来检测其边缘
%# 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中没有找到用于Hough变换的代码或函数来检测这样的平滑曲线(例如,二次多项式:y = a * x ^ 2).任何其他解决方案也欢迎.
这是原始图片:
如果觉得《利用matlab检测曲线 如何在matlab中检测平滑曲线》对你有帮助,请点赞、收藏,并留下你的观点哦!