Sobel operator
Next on our list we have the sobel filter, yet another filter which serves to extract an outline map of the original image. The filter works quite simply,we just colvolvue a kernel of a determinate length, (3 for most cases) against a particular set of values. We sum this up and assign the current pixel the value after applying the gradient magnitue formula over it.
Comparing the Sobel Filter to the Laplacian Filter, we find that the Sobel operator is faster and generally produces cleaner output. However, there is a trade-off, as it may lose certain finer details in the image. This makes the Sobel filter particularly useful when we only need to focus on extracting the edges of larger objects in the image. For instance, in a self-driving car system, where detecting the car's boundaries is crucial, neglecting dust, scratches, or other minor details in favor of clear object boundaries becomes more important.
Implementation
The sobel filter is implemented at src/edge-detection/sobel.c
As you can see, we first convert the image to grayscale, looping across each pixel we then convulve each with an area of SOBEL_K_SIZE
which in this case is 3
, we then add to the sumX
and the sumY
the kernels.
Let's actually loook at the kernels in question
Each kernel serves to calculate the gradient of the image in a particular direction, this will create a "ghost" like imprint of the edges for each of the gradient directions, on extracting the root of the squared sum we can effectively extract the edges.
Result
Last updated