I need to extend lines over the image space. I used Hough transform to finde vanishing lines, but i need to get lines longer and see where is vanishing points. How can i do it? Please help. enter image description here This is my code:

clear; clc;

I = imread('22pp.jpg');

%rotI = imrotate(I,33,'crop');
bw_I = rgb2gray(I);
BW = edge(bw_I,'canny');

figure, imshow(BW); %pause;


figure, imshow(BW); %pause;

[H,T,R] = hough(BW);
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P  = houghpeaks(H,15,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',200,'MinLength',200);
figure, imshow(I), hold on

for k = 1:length(lines)
   xy = [lines(k).point1; lines(k).point2];
   plot( xy(:,1) ,  xy(:,2),  'LineWidth',2,'Color','green');

   % Plot beginnings and ends of lines

2 Answers 2


Fit a line through the end points using standard line model $ax+by+c=0$. Then draw them on the image from -10000, 10000. The points remaining on the image will give you what you are asking for.


A very simple numerical approach:

  • Pad your image with zeros up to the size that you want the final image/lines to be

  • Run your Hough transformation code

  • Draw the lines in the padded image

The zeros don't give you additional signal in the Hough transformation, hence the resulting lines will be the same. By padding the image, you enlarge the area to paint the lines onto.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.