Skip to content

Edge detection on achromatic images written in pure C

License

Notifications You must be signed in to change notification settings

pcichowski/edge-detection

Repository files navigation

Canny Edge Detection

Edge detection on achromatic images written in pure C,
based on the algorithm created by John F. Canny

Algorithm

The algorithm works by performing matrix convolutions in a few steps:

  1. Noise reduction - 5x5 Gaussian filter
  2. Finding intensity gradient - vertical and horizontal Sobel kernel
  3. Non-maximum suppression
  4. Hysteresis thresholding

Thresholding is defined by two parameters - lower and upper threshold

Examples

architecture_resized






car_resized






city_chicago_resized






city_la_resized






lizard_resized


Conclusion

Canny edge detector algorithm uses two thresholds. I concluded that it is difficult to find these values, having to tweak them for each image and still getting unsatisfactory results. For now, the program in this form works quite well for straight lines, mainly architecture or car designs. It's effectiveness falls of when it comes to pictures with nature or animals.

Usage

If you wish to try the program, follow these steps

  • To work, the program needs the following file structure:

edge_detection_c.exe
--images/
----input/
----output/
  • Place images you want to detect edges on in the input folder

    • Note: For now, the only supported image extension is .jpg

  • Execute the program

Images with detected edges are placed into the output folder with the same name and extension

Credits

License

This project is a free and open-source software licensed under the MIT license

Acknowledgments:

Used STB library developed by nothings for loading and saving to jpegs