Edge Detection
Edge detection it is an old problem in computer vision applications which is used to detecting the edges in an image to determine object boundary and separate the object of interest. In this Edge detection the most popular technique is Canny Edge detection which has been the go-to method for most of the computer vision researchers and practitioners. Let’s have a quick look at Canny Edge Detection.
Canny Edge Detection Algorithm
Canny Edge detection this algorithm was invented by John Canny in 1983 at MIT. It gives the edge detection is a signal processing problem. The key idea of Canny Edge Detection is that if you observe the change in intensity on each pixel in an image, it’s very high on the edges.
In below simple image, the change in intensity only happens on the boundaries. So, by observing this you can very easily identify edges just by the change in intensity.
Just look at the above image the intensity is not constant but the rate of change of intensity is high at the edges, basically the edge detection is done in four steps they are
1. Noise Removal.
2. Gradient Calculation.
3. Non-Maximal Suppression.
4. Hysteresis Thresholding.
Noise removal:
Noise removal method depends on if the image has a lot of noise and sudden changes in the intensity that can be detected as an edge. So, it’s a very good idea to smoothen the image using a Gaussian filter of 5×5.
Gradient Calculation:
After noise removal, in the next step, we can calculate the gradient of intensity(rate of change in intensity) on each and every pixel in the image and we can also calculate the direction of the gradient.
Basically the Gradient direction is perpendicular to the edges And It’s mapped to one of the four directions (horizontal, vertical, and two diagonal directions).
Non-Maximal Suppression:
In this Non-Maximal Suppression we want to remove the pixels values(set their values to 0) which are not edges in our image and You can say that we can simply pick the pixels values with the highest gradient values or intensity values and directly take it as those are our edges, but in real-world images, gradient doesn’t simply peak at one pixel, rather it’s very high on the pixels near the edge as well. So, we pick the local maxima in a neighborhood of 3×3 in the direction of gradients.
Hysteresis Thresholding:
After that In the next step, we have to decide on a threshold value of the gradient below which all the pixels would be suppressed (set to zero). However, Canny edge detector using Hysteresis thresholding. Hysteresis thresholding is one of the very simple yet powerful ideas. The main advantage of the hysteresis Thresholding is that in place of using just one threshold we would use two thresholds:
High threshold= A very high value is chosen in such a way that any pixel having gradient value higher than this value is definitely an edge.
Low threshold= A low value is chosen in such a way that any pixel having gradient value below this value is definitely not an edge.
Pixels having gradients between these two thresholds are checked if they are connected to an edge, if yes, then they are kept else suppressed.
The main problem of Canny Edge Detector is only focuses on local changes it does not have semantic understanding (understanding the content of the image).
But the semantic understanding is very crucial for edges detection. So that is why learning based detectors which uses machine learning or deep learning generate better results than canny edge detector.
We can see the edge detection with DNN in our next post.