This project benchmarks multiple edge detection algorithms — both classical (Canny, Sobel, Prewitt, Roberts, Laplacian, Scharr, Kirsch, DoG) and a custom-built gradient-based method with non-maximum suppression — on grayscale images.
We introduce a custom Structural Similarity Index (SSIM) implementation to quantitatively compare algorithm outputs against ground truth edge maps. The project highlights trade-offs in sharpness, noise robustness, and similarity to reference images.
- Input images loaded in grayscale
- Optional Gaussian smoothing
- Sobel
- Prewitt
- Roberts
- Laplacian
- Scharr
- Canny
- Kirsch
- Difference of Gaussians (DoG)
- Gradient-based detector with Non-Maximum Suppression + thresholding
- Custom SSIM metric coded from scratch
- Comparison of each method's output to ground truth
- Quantitative scores + qualitative visualization
SSIM scores range between -1 (no similarity) and 1 (perfect similarity).
| Method | SSIM Score |
|---|---|
| Canny | 0.85 |
| Sobel | 0.78 |
| Prewitt | 0.74 |
| Laplacian | 0.69 |
| Custom | 0.88 |
Key Finding: Custom-built gradient model achieved the highest SSIM, showing competitive results with classical detectors.
git clone https://github.com/yourusername/edge-detection-comparison-ssim.git
cd edge-detection-comparison-ssimpip install -r requirements.txtnumpy
opencv-python
matplotlib
pillow
python src1.pypython test.py- Side-by-side edge maps for each method
- SSIM score annotations on each plot
- Saved PNG outputs for reproducibility
Input Image → [Canny] [Sobel] [Prewitt] [Custom]
SSIM: 0.85 0.78 0.74 0.88
- Add modern deep learning detectors (e.g., Holistically-Nested Edge Detection, U²-Net)
- Extend evaluation metrics beyond SSIM (PSNR, F1-score vs ground truth)
- Optimize custom algorithm for speed using CUDA kernels
- Package into a benchmarking toolkit for CV researchers
edge-detection-comparison-ssim/
├── data/
│ ├── input/
│ └── ground_truth/
├── outputs/
│ └── edge_maps/
├── src1.py
├── test.py
├── requirements.txt
└── README.md
Our custom implementation includes:
- Gradient Computation: Calculates image gradients in x and y directions
- Non-Maximum Suppression: Thins edges to single-pixel width
- Double Thresholding: Identifies strong and weak edges
- Edge Tracking: Connects weak edges to strong edges
Custom SSIM calculation from scratch:
- Luminance comparison
- Contrast comparison
- Structure comparison
- Combined metric with configurable weights
[Aarush C V]
[aarushinc1@gmail.com]
- Classical edge detection algorithms from computer vision literature
- SSIM metric based on the paper by Wang et al. (2004)
- Canny, J. (1986). A Computational Approach to Edge Detection
- Wang, Z., et al. (2004). Image Quality Assessment: From Error Visibility to Structural Similarity