Question: Hello, I'm trying to detect driving lanes using hough transform in MatLab. I think I've been successful except when the lines intercept i want them
Hello, I'm trying to detect driving lanes using hough transform in MatLab. I think I've been successful except when the lines intercept i want them to stop.

Here is all of my code:
a=imread('road.jpg');
imshow(a);
g=rgb2gray(a);
BW = edge(g,'Canny'); %The Hough transform maps all points from the binary image %into space s and creation of accumulation array A: imshow(BW); [A,theta,s] = hough(BW);
%In the accumulation array A are finding peak values, which represent %potential lines in the input image
P = houghpeaks(A,2,'threshold',ceil(0.5*max(A(:))));
%The resulting detected lines are extracted from the coordinates of found %peaks of the binary image
lines = houghlines(BW,theta,s,P,'FillGap',50,'MinLength',40);
figure, imshow(g), hold on max_len = 0; 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 plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow'); plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
end
Please explain the changes if possible.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
