views:

446

answers:

3

So I have Image like this

 CG generated bathroom

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

 Black & White CG generated bathroom with some red lines  between tiles

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.

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

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

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

+1  A: 

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.

jeff7
It looks grate!)
Blender
+2  A: 

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..

Amro
Hough Transform is quite slow... And I have to work with 2k live video...
Blender
A: 

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.

bjwhitcher