You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's create a tool to detect edges of an image! To do so we'll use the Sobel operator/filter (there are other techniques out there, e.g. Canny edge detector). The matrices associated with the kernels we'll be using are given by:
Think of $G_x$ and $G_y$ as maps of the form $\mathbb{R}^{3\times3}\rightarrow\mathbb{R}$, where we take in a 3 by 3 patch of image (denoted by $A\in\mathbb{R}^{3\times3}$), do some operation on it (using the matrices shown above), and return a real number (the value of the pixel for the output image). So, for example, if we are given the following patch of grayscale image:
To apply the Sobel operation to that patch of image we want to calculate:
$$
\sqrt{[G_x(A)]^2+[G_y(A)]^2}
$$
which in the case of this example is equal to 174.917. This number will be the pixel contained in the output image. For now it's ok to have values which are out of the [0,255] range because at the very end we will normalize the image values. Notice that the output will be always greater than or equal to zero. We do this operation for the entire input image and create a new image based on these outputs just describe above.
This completes the application of the edge detection technique. If you are interested I have a couple of videos showing some details on YouTube:
Sobel Filter - Part 1 and Sobel Filter - Part 2.
About
A python code showing how to apply a Sobel filter for edge detection.