matlab实现sobel边缘检测和霍夫变换找直线
时间: 2023-12-28 20:03:21 浏览: 89
matlab-图像边缘检测,包括sobel,hough直线提取以及SUSAN角点提取-源码
可以的,以下是matlab代码实现sobel边缘检测和霍夫变换找直线:
sobel边缘检测代码:
img=imread('test.jpg');
grayImg=rgb2gray(img);
sobelImg=edge(grayImg,'sobel');
imshow(sobelImg);
霍夫变换找直线代码:
[H,theta,rho] = hough(sobelImg);
peaks = houghpeaks(H,5);
lines = houghlines(sobelImg,theta,rho,peaks,'FillGap',5,'MinLength',7);
figure, imshow(img), 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');
end
阅读全文