← Back to the site
Sep 2025 – Oct 2025University of Twente

Traditional Lane Detection using Image Processing

Computer VisionImage Processing

Deep learning solves lane detection well, which is exactly why I wanted to try it without any. I took footage shot from a car on a Dutch motorway and rebuilt lane detection using only classical image processing.

Finding edges turned out to be the easy part. Canny returns the lane markings, and also every vehicle, building, pole, signboard, median and road border in the frame. Worse, many of those are near-vertical lines running parallel to the road, which is precisely what a lane looks like to an algorithm. The project became an exercise in throwing information away without losing the two lines I actually wanted.

I worked it into a pipeline where each stage removes a class of false positive: blur away texture, close broken markings with dilation and restore their scale with erosion, cut the frame down to a trapezoid covering only the road ahead, then pull line segments out with the Hough transform and filter them by angle before extending them into lane markers.

The pipeline:

  1. Convert frames to greyscale to work on intensity rather than colour.
  2. Apply a Gaussian filter to reduce noise.
  3. Run Canny edge detection.
  4. Dilate to fill gaps and merge nearby edges.
  5. Erode to bring the dilated image back to size.
  6. Detect shapes to find polygons in the image.
  7. Apply a trapezoidal mask to focus on the region of interest.
  8. Re-run Canny inside the masked region.
  9. Apply the Hough transform to find line segments.
  10. Filter vertical lines by threshold and extend the rest into lane markers.

A good reminder that much of computer vision is deciding what to ignore.

Lane lines detected on the motorway footage.
Lane lines detected on the motorway footage.
Every stage of the pipeline, from raw frame to extended lane lines.
Every stage of the pipeline, from raw frame to extended lane lines.
← Back to the site