如何使用Haar小波来检测图像上系? [英] How to use Haar wavelet to detect LINES on an image?

查看:418
本文介绍了如何使用Haar小波来检测图像上系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有图片类似这样

So I have Image like this

我想是这样的(我hevent画我希望所有的行,但我希望你能得到我的想法)

I want to get something like this (I hevent drawn all lines I want but I hope you can get my idea)

我想用SURF((快速鲁棒特征)是一个强大的图像描述符,由赫伯特·湾等psented第一$ P $,2006年),或东西,是基于二维Haar小波响应款项,使一个有效地利用积分图像寻找图像的所有直线。我想获得相对于图片像素的coords就行了终点。

I want to use SURF ( (Speeded Up Robust Features) is a robust image descriptor, first presented by Herbert Bay et al. in 2006 ) or something that is based on sums of 2D Haar wavelet responses and makes an efficient use of integral images for finding all straight lines on image. I want to get relative to picture pixel coords start and end points of lines.

因此​​,在这个图片上找到顶部瓦片和thouse 2黑线之间的所有行。

So on this picture to find all lines between tiles and thouse 2 black lines on top.

是否有这样的code为例(与线搜索功能),从开始?

Is there any such Code Example (with lines search capability) to start from?

我爱C和C ++,但任何其它可读code可能会为我工作=)

I love C and C++ but any other readable code will probably work for me=)

推荐答案

下面是应用的一个完整的例子 Hough变换以检测线。我使用MATLAB的工作。

The following is a complete example of applying Hough Transform to detect lines. I am using MATLAB for the job..

诀窍是将图像划分为区域和过程中的每个不同的;这是因为你在场景中不同的纹理(上墙的上部区域瓦片从底部较深的人完全不同,并处理图像一下子不会是最优的)。

The trick is to divide the image into regions and process each differently; this is because you have different "textures" in your scene (tiles on the upper region of the wall are quite different from the darker ones on the bottom, and processing the image all at once wont be optimal).

作为一个工作的例子,看看这个例子:

As a working example, consider this one:

%# load image, blur it, then find edges
I0  = rgb2gray( imread('http://www.de-viz.ru/catalog/new2/Holm/hvannaya.jpg') );
I = imcrop(I0, [577 156 220 292]);     %# select a region of interest
I = imfilter(I, fspecial('gaussian', [7 7], 1), 'symmetric');
BW = edge(I, 'canny');

%# Hough Transform and show accumulated matrix
[H T R] = hough(BW, 'RhoResolution',2, 'Theta',-90:0.5:89.5);
imshow(imadjust(mat2gray(H)), [], 'XData',T, 'YData',R, ...
       'InitialMagnification','fit')
xlabel('\theta (degrees)'), ylabel('\rho')
axis on, axis normal, colormap(hot), colorbar, hold on

%# detect peaks
P  = houghpeaks(H, 20, 'threshold',ceil(0.5*max(H(:))));
plot(T(P(:,2)), R(P(:,1)), 'gs', 'LineWidth',2);

%# detect lines and overlay on top of image
lines = houghlines(BW, T, R, P, 'FillGap',50, 'MinLength',5);
figure, imshow(I), 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

您可以尝试进行相同的操作等地区,同时调整参数,以获得较好的效果。

You could try the same procedure for other regions while tuning the parameters to get good results..

这篇关于如何使用Haar小波来检测图像上系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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