Canny Edge Detection is a fundamental image processing technique that identifies edges in images. It is widely used in various computer vision applications, such as object detection, image segmentation, and motion tracking.
This project implements Canny Edge Detection from scratch in Python. It follows the five main steps of the algorithm:
-
Grayscale Conversion: Color images are converted to grayscale, making edge detection simpler.
-
Gaussian Blurring: The image is filtered with a Gaussian kernel to reduce noise, enhancing edge detection accuracy.
-
Gradient Estimation: The strength and direction of gradients are estimated using Sobel filters.
-
Non-Maximum Suppression: We ensure that edges are one pixel thick by suppressing non-maximum gradients along the gradient's normal direction.
-
Dual Thresholding: Finally, strong gradient pixels are connected using a dual threshold to create the final edge image.
You can use this Canny Edge Detection implementation with your own images. Simply replace image_name
with the path to your image and adjust the threshold values if needed.
The result is a one-pixel thick edge-detected image with clear and well-connected edges.
Original Image | Canny Edge Detection |
---|---|
I provide a comparison with OpenCV's Canny Edge Detection to verify my implementation's accuracy.
- Python
- OpenCV
- NumPy
- Matplotlib
This project is open-source under the MIT License. Feel free to use, modify, and share.