Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用matlab实现不同θ区间的Hough变换_Matlab_Image Processing_Computer Vision - Fatal编程技术网

用matlab实现不同θ区间的Hough变换

用matlab实现不同θ区间的Hough变换,matlab,image-processing,computer-vision,Matlab,Image Processing,Computer Vision,matlab中的hough变换按以下方式调用: [H, theta, rho] = hough(BW) 如果我想指定θ值,我可以使用 [H, theta, rho] = hough(BW, 'Theta', 'begin:step:end') θ参数指定Hough变换θ值的向量。我的问题是Matlab中θ值的可接受范围在-90到90度之间。我想计算θ值在0到180度之间的hough变换。我应该在matlab中重新实现hough变换吗?在hough变换中是否有其他代码允许此范围 根据霍夫变换的

matlab中的hough变换按以下方式调用:

[H, theta, rho] = hough(BW)
如果我想指定θ值,我可以使用

[H, theta, rho] = hough(BW, 'Theta', 'begin:step:end')

θ参数指定Hough变换θ值的向量。我的问题是Matlab中θ值的可接受范围在-90到90度之间。我想计算θ值在0到180度之间的hough变换。我应该在matlab中重新实现hough变换吗?在hough变换中是否有其他代码允许此范围

根据霍夫变换的定义,
r(roh,theta)=r(-roh,theta+180)
。你可以水平翻转你得到的-90:0的数据,你将得到90:180的数据

以下代码使用文档中的示例,并360度完整地完成数据:

%example code
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(3,1,1);
imshow(RGB);
title('Gantrycrane Image');

% Display the Hough matrix.
subplot(4,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);

%Modifications begin
subplot(3,1,3);
%append another 180 degree to the axis
T2=[T T+180];
%append flipped data
H2=[H,H(end:-1:1,:)];
%plot the same way.
imshow(imadjust(mat2gray(H2)),'XData',T2,'YData',R,...
      'InitialMagnification','fit');
title('Hough Transform of Gantrycrane Image');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(hot);

这听起来有点傻,但是你怎么知道matlab-90到90不是你的0到180度?从哪里到哪里定义θ?如果这是一个问题,你也可以将
BW
旋转90度(
rot90
imrotate
,“BW”等)@natan谢谢你的回答。但我还是很困惑。我认为负角度发生在顺时针方向。例如-90=270度和90=-270度。所以我的时间间隔应该在0到-180度之间,或者在0到180度之间,根据matlab,这是不可能的范围。如果我将BW逆时针旋转90度,范围(-90,90)将真正代表范围(0180)?:非常感谢你的回答。但我忘了提到,我还想在hough变换后建立角度值的直方图。我应该对H的列求和以实现我想要的吗?