【发布时间】:2017-01-26 15:59:31
【问题描述】:
我对 Octave 上的图像处理和霍夫变换很感兴趣,但结果不是预期的。 这是我的边缘图像: 这是我的霍夫累加器(x 轴是角度,y 轴是半径): 我觉得我错过了水平条纹,但 0/180 角度值的累加器中没有局部最大值。
另外,对于垂直条纹,半径的值应该等于边缘图像的 x 值,但是 r 的值非常高:
exp:图像左侧的第一条垂直线有一个方程 x=20(approx) -> r.r = x.x + y.y -> r=x -> r=20
检测到的整体结果线与边缘完全不匹配:
- 检测到最大值的蓄能器:
- 结果行:
如您所见,累加器的最大值已令人满意地检测到,但结果线的半径值太高且缺少 theta 值。
看起来霍夫变换累加器与图像不对应......
谁能帮我弄清楚为什么以及如何纠正它? 这是我的代码:
function [r, theta] = findScratches (img, edge)
hough = houghtf(edge,"line", pi*[0:360]/180);
threshHough = hough>.5*max(hough(:));
[r, theta] = find(threshHough>0);
%deg to rad for the trig functions
theta = theta/180*pi;
%according to octave doc r range is 2*diagonal
%-> bring it down to 1*diagonal or all lines are out of the picture
r = r/2;
%coefficients of the line y=ax+b
a = -cos(theta)./sin(theta);
b = r./sin(theta);
x = 1:size(img,2);
y = a * x + b;
figure(1)
imagesc(edge);
colormap gray;
hold on;
for i=1:size(y,1)
axis ij;
plot(y(i,:),x,'r','linewidth',1);
end
hold off;
endfunction
提前谢谢你。
【问题讨论】: