1.hought函数
语法:[H, theta, rho] = hough(BW)
[H, theta, rho] = hough(BW, ParameterName, ParameterValue)
描述:[H, theta, rho] = hough(BW)计算二值图像BW的标准hough变换。函数返回的H称为hough转换矩阵。theta和rho是一维数组,theta记录径,rho记录角度。BW可以是逻 辑型,也可以是数值型。
[H, theta, rho] = hough(BW, ParameterName, ParameterValue)通过 名字/值 对计算标准hough变换。当ParameterName是 'RhoResolution' 时,用ParameterValue 指定一个位于0到 norm(size(BW))间的实散值去作为hough转换的径(rho轴)的步长,默认值为1。当 ParameterName是 'Theta' 时,用ParameterValue指定 一个矢 量去作为hough转换的角度范围,可接受的范围为-90<=theta<90。默认值为-90:89.
例子:
RGB = imread('gantrycrane.png');
% Convert to intensity.
I = rgb2gray(RGB);
% Extract edges.
BW = edge(I,'canny');
[H,T,R] = hough(BW,'RhoResolution',0.5,'Theta',-90:0.5:89.5);
% Display the original image.
subplot(2,1,1);
imshow(RGB);
title('Gantrycrane Image');
% Display the Hough matrix.
subplot(2,1,2);
imshow(imadjust(mat2gray(H)),'XData',T,'YData',R,...
'InitialMagnification','fit');
title('Hough Transform of Gantrycrane Image');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(hot);