How it works...

Formally, the Laplacian of a 2-D function is defined as the sum of its second derivatives:

In its simplest form, it can be approximated by the following 3 x 3 kernel:

0

1

0

1

-4

1

0

1

0

As with the Sobel operator, it is also possible to compute the Laplacian using larger kernels, and since this operator is even more sensitive to image noise, it is desirable to do so (unless computational efficiency is a concern). Since these larger kernels are computed using the second derivatives of the Gaussian function, the corresponding operator is often called the Laplacian of Gaussian (LoG). Note that the ...

Get OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.