Skip to content

CS4372 - Machine Vision - Canny Edge Detection from Scratch - Python Image Processing

License

Notifications You must be signed in to change notification settings

imshaaz21/CannyEdgeDetection

Repository files navigation

Canny Edge Detection from scratch

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:

  1. Grayscale Conversion: Color images are converted to grayscale, making edge detection simpler.

  2. Gaussian Blurring: The image is filtered with a Gaussian kernel to reduce noise, enhancing edge detection accuracy.

  3. Gradient Estimation: The strength and direction of gradients are estimated using Sobel filters.

  4. Non-Maximum Suppression: We ensure that edges are one pixel thick by suppressing non-maximum gradients along the gradient's normal direction.

  5. Dual Thresholding: Finally, strong gradient pixels are connected using a dual threshold to create the final edge image.

Usage

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.

Result

The result is a one-pixel thick edge-detected image with clear and well-connected edges.

Original Image Canny Edge Detection
Original Image Canny Edge Detection Result

OpenCV Comparison

I provide a comparison with OpenCV's Canny Edge Detection to verify my implementation's accuracy.

Dependencies

  • Python
  • OpenCV
  • NumPy
  • Matplotlib

License

This project is open-source under the MIT License. Feel free to use, modify, and share.


GitHub Repository Link

About

CS4372 - Machine Vision - Canny Edge Detection from Scratch - Python Image Processing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published