How to use Haar wavelet to detect LINES on an image?

前端 未结 3 1726
不知归路
不知归路 2021-01-02 15:41

So I have an image like this:

\"

I want to get something like this (I haven\'t

相关标签:
3条回答
  • 2021-01-02 15:50

    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
    

    alt text

    alt text

    alt text

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

    0 讨论(0)
  • 2021-01-02 16:05

    Have you tried a simpler approach such as the Hough transform for finding lines? A function to perform this and example are included in OpenCV called cvHoughLines2.

    0 讨论(0)
  • 2021-01-02 16:12

    Two-dimensional wavelet transforms are implemented in R using the package waveslim. Specifically, the function dwt2D() uses a C "backend" for speed. You can then apply thresholding to find the lines.

    0 讨论(0)
提交回复
热议问题