www.gusucode.com > images 案例代码 matlab源码程序 > images/ComputeHoughTransformOverLimitedThetaRangeExample.m

    %% Compute Hough Transform Over Limited Theta Range
%
%%
% Read image and convert it to grayscale.
RGB = imread('gantrycrane.png');
I  = rgb2gray(RGB); 
%%
% Extract edges.
BW = edge(I,'canny'); 
%%
% Calculate the Hough transform.
[H,T,R] = hough(BW, 'Theta', 44:0.5:46);
%%
% Dislay the Hough transform.
figure
imshow(imadjust(mat2gray(H)),'XData',T,'YData',R,...
   'InitialMagnification','fit');
title('Limited Theta Range Hough Transform of Gantrycrane Image');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal;
colormap(gca,hot)