This project implements a complete lane detection pipeline using OpenCV and traditional computer vision techniques.
It demonstrates the end-to-end process of detecting road lane markings from an image using noise filtering, edge detection, Hough Transform, and RANSAC line fitting β without using deep learning models.
- Loaded a road image and converted it to grayscale.
- Added and analyzed Gaussian and Salt & Pepper noise for robustness testing.
- Applied multiple denoising filters (Gaussian, Median, Bilateral) and evaluated their performance using PSNR.
- Detected edges automatically using a custom Auto-Canny function based on image statistics.
- Used Hough Line Transform and RANSAC algorithms to extract dominant lane lines.
- Compared both methods quantitatively using coverage metrics and visual overlays.
| Stage | Technique | Purpose |
|---|---|---|
| Preprocessing | Grayscale Conversion | Simplify computation |
| Noise Simulation | Gaussian / Salt & Pepper | Evaluate denoising methods |
| Denoising | Gaussian / Median / Bilateral filters | Remove image noise |
| Edge Detection | Auto-Canny | Extract lane boundaries |
| Line Detection | HoughLinesP & RANSAC | Estimate lane lines |
| Evaluation | PSNR & Line Coverage | Quantify filtering and line quality |
-
Load and preprocess image
- Convert to grayscale
- Add noise for evaluation
-
Apply filters
- Gaussian blur
- Median blur
- Bilateral filtering
-
Measure PSNR
- Quantify denoising performance
-
Edge Detection
- Use auto-threshold Canny edge detector
-
Line Detection
- Detect lines with Hough Transform
- Fit lane lines with RANSAC (left/right lanes separately)
-
Compare methods
- Calculate coverage between detected lines and actual edges
- Overlay RANSAC (red) vs Hough (green) on the image
| Method | Description | Output |
|---|---|---|
| Gaussian Denoising | Smooths random noise | |
| Auto-Canny | Adaptive edge detection | |
| Hough vs RANSAC | Line detection comparison |
RANSAC (red) offers cleaner, more stable lane lines than Hough (green), especially in noisy or uneven lighting conditions.
pip install opencv-python matplotlib numpyEvaluation Metrics
PSNR (Peak Signal-to-Noise Ratio): Measures image quality after denoising.
Line Coverage (%): Percentage of edge pixels covered by detected lines (for both Hough and RANSAC).
π Key Functions:
add_gaussian_noise() / add_salt_pepper() β Adds noise for testing
auto_canny() β Automatically selects Canny thresholds
detect_lines_houghp() β Detects lines using Hough transform
ransac_line_fit() / ransac_side() β Fits left/right lane lines robustly
line_coverage() β Quantifies detection quality
π Concepts Demonstrated:
Noise modeling and denoising evaluation
Adaptive edge detection
Line detection using Hough and RANSAC
Quantitative evaluation with PSNR and coverage metrics