Image Processing & Filtering

laplacian operator

The Laplacian operator is a second-derivative filter: instead of measuring how fast brightness changes (the gradient), it measures how fast that rate of change is itself changing, in effect, how much a pixel differs from the average of its neighbours. It is isotropic, responding to intensity change in every direction at once with a single scalar value rather than a directional vector, which makes it a natural blob and edge detector that does not care about orientation.

Mathematically the Laplacian is the sum of the unmixed second partial derivatives, written nabla-squared f = d2f/dx2 + d2f/dy2. On a pixel grid it is approximated by the kernel with rows [0, 1, 0], [1, -4, 1], [0, 1, 0] (or [1, 1, 1], [1, -8, 1], [1, 1, 1] including diagonals). The key behavioural fact is that edges appear in the Laplacian not as peaks but as zero-crossings: as you pass through an edge the second derivative swings from strongly positive to strongly negative, crossing zero exactly at the edge. Locating those sign changes gives sub-pixel edge positions, the basis of Marr-Hildreth edge detection.

Because second derivatives amplify noise even more violently than first derivatives, the raw Laplacian is almost never used alone. The fix is to smooth with a Gaussian first, giving the Laplacian-of-Gaussian (LoG), a single kernel shaped like a Mexican hat that simultaneously blurs and takes the second derivative; its width sigma selects the scale of features detected. The LoG is closely approximated by the Difference of Gaussians (DoG), subtracting two Gaussian-blurred images, which is what the SIFT detector uses to find scale-invariant keypoints. The Laplacian also powers sharpening: adding a scaled negative Laplacian back to the image, output = f - c * nabla-squared f, boosts edges.

Across a soft light-to-dark ramp, the Laplacian reads positive on the bright shoulder, negative on the dark shoulder, and exactly zero at the inflection point, mark that zero-crossing and you have located the edge to sub-pixel precision.

Pitfall: a bare Laplacian on a noisy image is almost useless, every speck of noise creates spurious zero-crossings. Always pair it with smoothing (use LoG/DoG), and remember edges are the zero-crossings, not the bright or dark extrema, which are the two sides of the edge.

Also called
Laplacian filterLaplacian of Gaussian (LoG)Marr-Hildreth