MATLAB中的Hough变换 [英] Hough transform in MATLAB

查看:239
本文介绍了MATLAB中的Hough变换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何使用Hough变换来检测二进制图像中最强的行:

Does anyone know how to use the Hough transform to detect the strongest lines in the binary image:

A = zeros(7,7);
A([6 10 18 24 36 38 41]) = 1;

使用(rho; theta)格式与theta在-45°到90°之间的45°步长°。如何在MATLAB中显示累加器数组。

Using the (rho; theta) format with theta in steps of 45° from -45° to 90°. And how do I show the accumulator array in MATLAB as well.

请提供任何帮助或提示?

Any help or hints please?

谢谢你好!

推荐答案

如果你有权访问图像处理工具箱,你可以使用函数 HOUGH HOUGHPEAKS HOUGHLINES

If you have access to the Image Processing Toolbox, you can use the functions HOUGH, HOUGHPEAKS, and HOUGHLINES:

%# your binary image
BW = false(7,7);
BW([6 10 18 24 36 38 41]) = true;

%# hough transform, detect peaks, then get lines segments
[H T R] = hough(BW);
P  = houghpeaks(H, 4);
lines = houghlines(BW, T, R, P, 'MinLength',2);

%# show accumulator matrix and peaks
imshow(H./max(H(:)), [], 'XData',T, 'YData',R), hold on
plot(T(P(:,2)), R(P(:,1)), 'gs', 'LineWidth',2);
xlabel('\theta'), ylabel('\rho')
axis on, axis normal
colormap(hot), colorbar

%# overlay detected lines over image
figure, imshow(BW), hold on
for k = 1:length(lines)
    xy = [lines(k).point1; lines(k).point2];
    plot(xy(:,1), xy(:,2), 'g.-', 'LineWidth',2);
end
hold off


这篇关于MATLAB中的Hough变换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆