Searching for the Right Threshold


https://behappy.me/generator

The topic for this exercise is Edge Detection. In my opinion, Edge detection is one of the things that should be fully understood because edge detection can be used in object detection, classification, feature extraction, and tracking.

The theory behind edge detection is all about derivatives or the rate of change. In the first order derivative, one can see that rate of change when you go through and image. While in the second order, the point where the graph crosses zero in the x-axis, that's when the rate of change is constant.

We were introduced to different kinds of edge detection kernels like Robert's, Prewitt's, Sobel's, and Scharr's. All of these kernels' sums are equal to zero. They only differ in the values. Then Canny edge detection was introduced. It is considered as an optimal detector and its algorithm goes like this:

  1. Filter an image using Gaussian filtering. 
    • Gaussian filtering was used because median filtering is slow while mean filtering leaves noises that could make the image's detected edges more inaccurate. Gaussian filtering focuses on the distribution on the pixel values of an image that's why is it more efficient and better to use.
  2. Apply convolutional masks to detect possible edges using Sobel's edge detection kernels.
  3. Apply non-maximum suppression.
  4. Apply hysteresis. 
    • Hysteresis uses two thresholds - a low threshold (tl) and a high threshlod (th), which is usually twice the low threshold (tl).
    • If pixel gradient is:
      • > th, then the pixel is an edge
      • < tl, then the pixel is not an edge
      • < th AND > tl, then the pixel is an edge connected to a pixel above th
The following week, we were tasked to gather forty (40) images of license plates of vehicles around the campus. For our exercise, using the Canny edge detection algorithm, we should be able to group the images on what thresholds of the Canny edge detection algorithm should we apply. Also, it should be done in a 1:2 ratio and in a 1:3 ratio.

Firstly, we divided the images based on the ranges of threshold we used which are:
  • 0 - 25
  • 26 - 50
  • 51 - 75
  • 76 - 100
The results are as follows:
threshold of 0-25
ratio 1:2 (left) and ratio 1:3 (right)

threshold of 26-50
ratio 1:2 (left) and ratio 1:3 (right)
threshold of 51-75
ratio 1:2 (left) and ratio 1:3 (right)
threshold of 76-100
ratio 1:2 (left) and ratio 1:3 (right)
The threshold depended on how noisy an image is and other conditions such as weather conditions (if an image was taken during the day or during a cloudy day) and the distance of how the image was taken. Usually, if an image was taken with high quality, a threshold between the range of 0-25 is enough. If an image was far, enough it would be between the ranges 26-75. And for noisy images, sometimes it goes up to 100. Also, we decided that as much as possible the edges of the letters are complete so even though the image is noisy as long as the edges of the lettters are complete, we considered that threshold.

The conclusion is looking for the optimal threshold varies per image. It depends on the quality of the image and the noise present in the image. 

Comments