跪求Hough变换检测直线的MATLAB源代码

来源:百度知道 编辑:UC知道 时间:2024/06/15 20:05:56
如题,要能直接运行,谢谢。

直接运行:

RGB = imread('gantrycrane.png');
I = rgb2gray(RGB); % convert to intensity
BW = edge(I,'canny'); % extract edges
[H,T,R] = hough(BW,'RhoResolution',0.5,'ThetaResolution',0.5);

% display the original image
subplot(2,1,1);
imshow(RGB);
title('gantrycrane.png');

% display the hough matrix
subplot(2,1,2);
imshow(imadjust(mat2gray(H)),'XData',T,'YData',R,...
'InitialMagnification','fit');
title('Hough transform of gantrycrane.png');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(hot);