Edge detection explained in 1D
Written by Akshay Chavan on #arccoder Blog
15 Jan 2017This post is inspired after watching edge detection (2A-L5,2A-L6) related lectures in the Introduction to Computer Vision course on Udacity. Here I have implemented the real world example shown in the using a 1D toy example.
Edges are the most basic and widely used features used in computer vision. Edges are formed when there is a steep change in the color or intensiy values in the image. To capture these high differnce ridges we can make use of differential opeartors to create masks that computer gradients.
Real world images or signals are never completelty noise free so first we need to smooth the signal using a low pass filter. In this case we have choosen a gausian filter as shown in Fig 1. (This post only implements 1D signal but the same logic can be extended to 2D signals.)
Because filtering or convolution is a linear operator, using the associative property of linear operators we can take derivatives of the filter and apply it directly to the signal rather than taking the derivative of the convolved signal and the filter.
Fig 2 shows the first derivative of the gaussian filter and the second derivative is shown in Fig 3.
The first order derivative will give the signal which peaks at the location of the largest gradient. But then we need to find the location of the peak to get the edge location. For that we can take another derivative and the location at which the signal crosses over zero thats the location of the peak.
No we apply the filters to the signal shown in Fig 4 with some noise added to it.
The figures 5, 7, and 8 show the output after been convoluted by the filters shown in figures 1, 2, and 3 respectively.
Fig 6 shows the output after taking the first derivative of the signal in Fig 5.
The output signals in figures 6 and 7 are equal. The only difference is the sequence in which the differentiation and convolution is applied.
Matlab code to generate the signals above can be found here.
Related Posts
How to sort columns on the fly while editing in Google Sheets : 01 Nov 2016How to create a button to sort columns in Google Sheets : 30 Oct 2016
How to use meanshift function from FastCV : 04 Oct 2016