In this section, we are going to look at yet another technique that is available for edge detection: Laplacian. Simply put, Laplacian is nothing but the second derivative of the image, where the second derivative refers to the derivative of the derivative. Mathematically, this is represented as follows:
When we were looking for edges using the first derivative, we saw that regions that are potentially edge regions have a sufficiently high magnitude of the derivative (gradient). As it turns out, in the same edge regions, the second derivative is zero. This phenomenon is used as a criterion to detect edges using the Laplacian operator.
The Laplacian()
function in OpenCV implements the Laplacian operator that we just discussed. In fact, a single call to Laplacian()
will handle both the dimensions, x and y. Internally, it calls the Sobel()
function to calculate gradients. A code snippet showing the implementation of Laplacian()
is as follows:
...