How may i draw a middle line and measure the horizontal detainees between this line and the other dashed two lines

2 views (last 30 days)
Hi Everyone
Im trying to write a Matlab code to detect the lans of a highway image. The way that it should work is by drawing line in the middle of the lane and then measure the horizontal distance between the middle line and the right & left dashed lines. This is my command
-------------------------------------
a = imread('1.jpg');
I=rgb2gray(a);
rn = wiener2(I,[20 20], 0.05);
d = graythresh(rn);
e = im2bw(rn,d);
BW = edge(e,'canny',[0.475,0.575],0.2);
BW(1:100, :, :)=0;
[H,theta,rho] = hough(BW,'Theta',-65:1:65);
P = houghpeaks(H,15,'threshold',ceil(0.3*max(H(:))));
lines = houghlines(BW,theta,rho,P,'FillGap',50,'MinLength',1);
imshow(a), hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',3,'Color','red');
L1=plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
L2=plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','green');
end
----------------------------------
<<
>>
This is how its look, It doesn't look as i want. I just wanna grow the middle line and measure the diatonic between the middle and the the detected lines( right and left)

Accepted Answer

Image Analyst
Image Analyst on 17 Mar 2015
I doubt it's going to be as simple as some 50 line long algorithm. Go here to find out the algorithms people have used successfully and published for lane following: http://www.visionbib.com/bibliography/contentsactive.html#Active%20Vision,%20Camera%20Calibration,%20Mobile%20Robots,%20Navigation,%20Road%20Following
15.3.3 Road, Path Following Operators
15.3.3.1 Road Following, Depth, Stereo Based, Off-Road, Safe Path
15.3.3.2 Lane Detection, Lane Following, White Line Detection
  4 Comments
Ahmed Alotaibi
Ahmed Alotaibi on 19 Mar 2015
That will be perfect if i do one of these.Actually,these questions comes to my mind always however i don't want to make a product. I'm trying to focus on putting the lane in the middle of these two weight lines and measure the distance which is relatively easier than considering other disturbances.could you please narrow my solution!
Image Analyst
Image Analyst on 20 Mar 2015
I don't know what diatonic means. And if you want to find distances between lines, simple algebra and the Pythagorean theorem would work. Not sure what you mean by "grow the line" but simple algebra will let you lengthen a line in the overlay, or if it's part of the image, imdilate will do that.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!