I am working on lane detection system and I would like some suggestions from you as to how to detect lanes from a filtered image which I got after performing certain operations. Firstly, I should mention a few things:

  1. The lane detection would be in a real road environment unlike here.
  2. As of now, I am running it in real-time (O(n)) to be precise, which I would like to maintain.

The following image shows the original image and my filtered image.

enter image description here

As you can see, there are false positives which I want to remove and that is my main problem. Now, these are the few approaches I have thought of:

  1. Check the intensity on the left and right hand side for desired areas. It should be high for desired area and low on both sides. **Problem: I am finding it difficult to define 'high' and 'low' since the method has to be independent of time of the day.

  2. One approach I thought was to check shapes but I can't think of any algorithm since those are not rectangles, those are essentially distorted parallelograms(?).

One more, I have seen people generate lines on these type of images using hough, this same question does that. If I run hough, I am not getting lines. Is the intensity of the image a problem or should I run Hough on binary mask image? I am currently doing this with MATLAB but I will be finally implementing with OpenCV to keep it real-time.


4 Answers 4


Finding shapes / lines is a good idea. Threshold tweaking is almost certainly a bad idea.

Hough transform typically expects your lines to be (1) in a binary image and (2) of one pixel width. Try to apply an edge detector (Matlab: edge) on your filtered image in order to get the boundaries of your white regions as one-pixel lines. Then Hough transform should find something.

I would also consider doing edge detection on your original image rather than your feature image. Then you can try to tweak the edge detector, rather than first running your "certain operations" and then detecting edges.

Once you have some lines you will face the problem of finding the good ones. You could look at (i.e. google for) "vanishing point detection", and read about RANSAC.


I was doing something similar for my Bachelor thesis. In combination with a friends thesis, we accomplished to to detect, follow, and recognize the type of the centerline in the image. I understand that you need lanes, and not centerlines, but I think a big majority of the approach is applicable, especially since you're planning to play with lines as well.

  • First step was to transform the perspective of the image. Our images (they looked very similar to yours), were taken from a camera mounted on top of the car. By applying the inverse perspective transform, we obtained the image from "bird-view" perspective. -- and there, the lines are almost parallel.

    If you want to detect lanes, that's what would fix your "it's a parallelogram, not a rectangle" problem.

  • Next step was image binarization (thresholding), which was not my part, but you have an excellent post on thresholding here.

  • Finally, we tried to fit a second order (quadratic) curve on the binarized image, using RANSAC (as @DCS mentioned) to get rid of the outliers.

  • Additionally, once the line would be detected, we would also limit the search space in the next image to the area close to the centerline detected in previous frame to achieve additional speed-up. (Don't forget: you have a video, where frames are consequential, not just a bunch of disconnected images)

    It worked pretty well, real time, got lost at strong turns sometimes, but not too often.

  • (Additionally, the idea we had for fixing the problems with strong turns, but which we have never implemented, is to try and fit a linear function to the centerline as well, and if it is not too bad compared to the fitted parabola, we would use that to estimate the next frame search space)

All in all, my part was only the perspective transform, so can't tell you more then just the general description of the rest.

We wrote a paper from those Bachelor theses, in which you can find all the details of what I just outlined in the answer:


This paper gives quite a lot of detail:


I don't have access to it anymore, but as I recall, it goes through an image processing pipeline from smoothing, edge detection, hough-transform and filtering. All done using Matlab+System Generator. There is a "less-formal" summary in Xilinx's journal here:


(I'll not say any more, given what I work on... :)

  • 2
    $\begingroup$ Can you please give a summary of the links, more than your current statement? Link-only answers tend to die after a while as sites get re-organized. $\endgroup$
    – Peter K.
    May 7, 2013 at 11:59

The following page might help

Road detetction

It gives results with different methods, and also explains them more or less.

  • 3
    $\begingroup$ Can you please give a summary of the link, more than your current statement? Link-only answers tend to die after a while as sites get re-organized. $\endgroup$
    – Peter K.
    May 7, 2013 at 11:57

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.