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)
Show older comments
Ahmed Alotaibi
on 17 Mar 2015
Commented: Image Analyst
on 20 Mar 2015
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)
0 Comments
Accepted Answer
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
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.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!