DEV Community

Docutain
Docutain

Posted on

Edge Detection for Image Processing

When it comes to image processing tasks, one needs to apply edge detection at some point. Edge detection means identifying and highlighting the boundaries or transitions between different regions in an image due to variety in brightness or intensity.


What is edge detection in image processing?
There are edge detection algorithms used to locate the boundaries of documents within a larger image. This enables efficient cropping, perspective correction and image extraction.

Typical approaches for document edge detection are Sobel Edge Detector, Canny Edge Detector and TensorFlow Edge Detector, which will be explained shortly in the following:


Sobel Edge Detector
This is one of the most often used techniques for edge detection with 3 options: You can get edges enhanced in the X-direction, edges enhanced in the Y-direction or edges enhanced in both directions.
For more details and code examples, please read the original article.

Canny Edge Detector
Canny makes use of Sobel as part of their edge detection alogrithms and constists of 5 steps:

  • Noise reduction
  • Gradient calculation
  • Non-maximum suppression
  • Double threshold
  • Edge Tracking by hysteresis thresholding

Code examples and images with Sobel and Canny outputs can be found in the original article.

One can detect that Sobel and Canny Edge Detector both have some trouble with noise in the examples shown. Therefore, there is another method to detect edges in images, the TensorFlow Edge Detection.

TensorFlow Edge Detection
TensorFlow is a machine learning framework which can be used for image processing, e.g. image classification or image segmentation. There is a simple idea behind on how to train a machine learning model using TensorFlow to predict edges in images. This is explained and shown with pictures in the article.

Conclusion
A recommendation on which model to use to detect edges in images and how to start doing so, can be found in the original article published here: [https://sdk.docutain.com/blogartikel/edge-detection-for-image-processing]

Top comments (0)