Key facts
- Laplacian: ∇²f = ∂²f/∂x² + ∂²f/∂y², the sum of second derivatives; it is rotation invariant.
- Discrete form: f(x+1) − 2f(x) + f(x−1) in each direction gives the 4-neighbour kernel [0 1 0; 1 −4 1; 0 1 0], with error of order h².
- Meaning: ∇²f ≈ 4 × (average of the 4 neighbours − f); it is zero on flat areas and ramps.
- Edges are the zero crossings of the Laplacian (the inflection points of the intensity profile).
- Noise: its frequency response grows as |ω|², so smooth first: LoG = ∇²Gσ * f, zero at r = √2σ.
- DoG Gkσ − Gσ ≈ (k − 1)σ²∇²Gσ; sharpening is g = f − c∇²f.
Slope and Curvature: What Derivatives Say About Edges
Take one row of pixels across the boundary between a dark field and a bright road in a satellite image. Because optics and sensors blur slightly, the brightness does not jump; it rises along a smooth S-shaped curve. Three curves describe that edge:
The first derivative is large where brightness changes quickly, so its peak marks the edge, but its height depends on the edge contrast and a threshold is needed to say where the peak is. The second derivative is positive where the profile curves upward (the dark foot of the edge), negative where it curves downward (the bright shoulder) and exactly zero at the inflection point between them. A sign change is a sharp, threshold-free location, which is the idea behind Laplacian edge detection.
Second Derivatives on a Pixel Grid: Finite Differences
Pixels are samples with spacing h = 1, so derivatives must be approximated from neighbouring values. Write the Taylor series of f one step to the right and one to the left:
Adding the two lines cancels every odd term:
Worked example. For the step f = [10, 10, 10, 10, 50, 50, 50, 50], applying [1 −2 1] gives [0, 0, 0, 40, −40, 0, 0, 0]: zero on both flat parts, +40 on the last dark pixel, −40 on the first bright pixel, and a sign change exactly between them. The central first difference (f(x+1) − f(x−1))/2 gives [0, 0, 0, 20, 20, 0, 0, 0], a plateau two pixels wide whose centre must still be located.
Deriving the 3 × 3 Laplacian Kernels
The 2-D Laplacian adds the second derivatives in x and y. Writing each as a 3 × 3 kernel and adding them gives the 4-neighbour Laplacian:
Three other kernels are common:
- 8-neighbour [1 1 1; 1 −8 1; 1 1 1]: add the second differences along the two diagonals to the 4-neighbour kernel. The diagonal neighbours are √2 pixels away, so for smooth images this kernel approximates 3∇², not ∇². It responds more evenly in all directions.
- Isotropic 9-point (1/6)[1 4 1; 4 −20 4; 1 4 1]: a weighted mix of the two that approximates ∇² and is rotation invariant up to fourth order in frequency.
- Positive-centre versions [0 −1 0; −1 4 −1; 0 −1 0] are simply −∇². Gonzalez and Woods and scikit-image use this sign; SciPy, OpenCV and MATLAB's fspecial use the negative centre. Always check which one a library or paper uses, because the sign of sharpening flips with it.
All Laplacian kernels share one property: their weights sum to zero, because the second derivative of a constant is zero.
What the Laplacian Value Means
Rearranging the 4-neighbour kernel gives the most useful intuition for the Laplacian:
| Situation | Neighbours vs pixel | Laplacian |
|---|---|---|
| Flat area | equal | 0 |
| Linear ramp (constant slope) | average equals pixel | 0 |
| Bright spot, bright side of an edge, top of a ridge | darker | negative |
| Dark spot, dark side of an edge, bottom of a valley | brighter | positive |
Worked example. A pixel of value 120 with neighbours 53 (north), 50 (east), 51 (south) and 52 (west): ∇²f = 53 + 50 + 51 + 52 − 4 × 120 = 206 − 480 = −274, or 4 × (51.5 − 120). A hot pixel, a bright star or a small bright building gives a strong negative response. The 8-neighbour kernel adds the diagonals (50, 48, 48, 52) and gives 404 − 8 × 120 = −556.
This "difference from the local average" view also explains the Laplacian's role in physics: in a steady state with no sources, every point equals the average of its surroundings, which is Laplace's equation ∇²u = 0.
Interactive Edge Explorer: f, f′ and f″
Choose a profile, add noise and smooth it. The charts show the (smoothed) signal, its central first difference and its second difference [1 −2 1], with zero crossings of strong lobes marked.
Three experiments are worth doing. Ramp: the second derivative is zero everywhere except at the corners, because a constant slope has no curvature. Thin line: the Laplacian gives a strong negative centre with two positive side lobes and therefore two zero crossings, one on each side of the line. Noise 3, smoothing 0: the second derivative is dominated by noise even though the edge is obvious in the signal; then raise the smoothing to 2 and the edge's zero crossing reappears. That is the whole motivation for the Laplacian of Gaussian.
The Noise Problem: Why the Laplacian Needs Smoothing
Differentiation multiplies a sinusoid of angular frequency ω by iω; doing it twice multiplies by −ω². The Laplacian therefore boosts each frequency in proportion to its square. Image structure lives mostly at low frequencies, while pixel noise is spread evenly up to the highest frequency, so the Laplacian amplifies noise far more than edges. The discrete kernels show this exactly:
For white noise of standard deviation σₙ, the 4-neighbour Laplacian outputs noise with standard deviation σₙ√(1 + 1 + 1 + 1 + 16) = σₙ√20 ≈ 4.47σₙ. A step of height 40 with noise σₙ = 10 gives an edge response of ±40 against noise of about 45: the edge is lost.
Interactive: frequency response of Laplacian kernels
The plain kernels keep rising to the highest frequency; the 4-neighbour kernel also responds less along the diagonal than along the axes, so it is not perfectly isotropic. The LoG rises like the ideal |ω|² at low frequencies, peaks at |ω| = √2/σ and then falls to zero: it is a band-pass filter tuned to structures of a chosen size.
The Laplacian of Gaussian (LoG): Derivation and the Mexican Hat
The fix is to smooth with a Gaussian filter first. Because convolution and differentiation are both linear and commute, the two steps combine into a single kernel:
To find ∇²G, differentiate G = (1/2πσ²)e−(x²+y²)/2σ² twice with respect to x using the chain and product rules:
- Shape: a negative centre and a positive ring; its negative, −∇²G, is the "Mexican hat" or Ricker wavelet.
- Zero crossing of the kernel at r = √2σ; its central lobe is 2√2σ wide.
- Discrete kernel: sample on a grid of radius about 4σ and shift it so its weights sum to zero; otherwise truncation leaves a small non-zero sum (−0.0127 for a 9 × 9 kernel with σ = 1.4) that adds a copy of the average brightness.
- Separable in practice: ∇²G = Gxx + Gyy, and each term is a product of 1-D kernels, so a LoG costs four 1-D passes.
Interactive: LoG and DoG profiles
The Marr–Hildreth edge detector (1980) is: convolve with the LoG, mark zero crossings, and keep those whose slope across the crossing is large. σ selects the scale: small σ finds fine, noisy edges; large σ finds only major boundaries, smoothly but with rounded corners. You can run it on your own image in the Laplacian Filter Tool.
Difference of Gaussians (DoG): Why It Approximates the LoG
The Gaussian satisfies the heat (diffusion) equation in the variable t = σ²/2: ∂G/∂t = ∇²G. Rewriting with σ gives
Two Gaussian blurs are each separable and cheap, and in a Gaussian pyramid they are computed anyway, so the DoG costs almost nothing extra. Marr and Hildreth found a ratio k ≈ 1.6 gives a good match to the LoG. Lowe's SIFT detector finds keypoints as extrema of the DoG across position and scale. The DoG also models the centre–surround receptive fields of retinal ganglion cells. As the demo above shows, a DoG with k = 1.6 crosses zero at the same radius as a LoG of scale σk√(2 ln k/(k² − 1)) ≈ 1.24σ. In other words, the DoG matches the shape of a LoG about 24% wider than σ, not the LoG at σ itself; the demo's 49% difference at k = 1.6 shrinks towards zero as k approaches 1.
Blob Detection and Automatic Scale Selection
The LoG responds most strongly to a blob whose size matches the kernel's central lobe. To compare responses across scales, the response must be scale-normalized by multiplying by σ² (Lindeberg); otherwise larger σ always gives smaller numbers. For a bright disc of radius R and unit contrast, the divergence theorem gives the response at its centre in closed form:
Interactive: which σ finds a blob of radius R?
This is how automatic scale selection works: compute σ²∇²G * f over a ladder of σ values and keep the local extrema in (x, y, σ). In remote sensing, the same idea counts and sizes tree crowns in high-resolution imagery, detects ponds or sinkholes in DEM-derived layers, and finds cells or particles in microscopy. On the pixel grid, the discrete LoG gives the best σ within a few percent of R/√2 (σ ≈ 5.5 for R = 8, against the theoretical 5.66).
The Laplacian Beyond Images
Heat and diffusion
∂u/∂t = D∇²u. Heat, pollutants and brightness all spread from high to low: a point warms when it is colder than the average of its surroundings (∇²u > 0).
Groundwater flow
Steady flow in a homogeneous, isotropic confined aquifer obeys Laplace's equation ∇²h = 0 for hydraulic head h. Finite-difference models solve it with exactly the 4-neighbour stencil.
Electrostatics and gravity
Poisson's equation ∇²φ = −ρ/ε₀ links potential to charge (see Maxwell's equations); the same form governs gravitational potential.
Graphs and machine learning
The graph Laplacian L = D − A (degree minus adjacency) is the positive version of the same operator. Its eigenvectors drive spectral clustering, and graph convolution networks use a normalized form of it.
Image quality control
The variance of the Laplacian is a standard focus measure: sharp images have a high variance and blurred ones a low variance. It is used to reject out-of-focus frames in drone and microscopy pipelines.
Multiresolution analysis
The Laplacian pyramid (Burt & Adelson, 1983) stores band-pass detail layers, the differences between successive Gaussian levels, for compression, blending and image fusion.
Laplacian Filter in Python
import numpy as np
from scipy import ndimage
f = img.astype(float) # never use uint8: negative values would wrap
# 1. plain Laplacian (4-neighbour) and its pixel-wise meaning
lap = ndimage.laplace(f) # = f_E + f_W + f_N + f_S - 4 f
# 2. Laplacian of Gaussian, scale-normalized
sigma = 2.0
log = sigma**2 * ndimage.gaussian_laplace(f, sigma)
# 3. zero crossings with a slope threshold (Marr-Hildreth)
def zero_crossings(L, thr):
"""Sign change to the right or below, with a jump larger than thr."""
z = np.zeros(L.shape, bool)
h = (L[:, :-1] * L[:, 1:] < 0) & (np.abs(L[:, :-1] - L[:, 1:]) > thr)
v = (L[:-1, :] * L[1:, :] < 0) & (np.abs(L[:-1, :] - L[1:, :]) > thr)
z[:, :-1] |= h
z[:-1, :] |= v
return z
edges = zero_crossings(log, thr=0.05 * np.percentile(np.abs(log), 99.5))
# 4. sharpening and the blur measure
sharp = np.clip(f - 1.0 * lap, 0, 255)
focus = lap.var() # variance of the Laplacian
Library equivalents: cv2.Laplacian(img, cv2.CV_64F, ksize=1) is the 4-neighbour kernel (its ksize=3 is a different kernel, [2 0 2; 0 −8 0; 2 0 2]); skimage.filters.laplace returns −∇²; MATLAB's edge(I, 'log') implements Marr–Hildreth and del2 returns ∇²/4.
Common Mistakes with the Laplacian Filter
- Computing in uint8. The Laplacian is signed; in 8-bit unsigned arithmetic negative values wrap around or clip to 0 and half the information is lost. Use float (or at least int16).
- Skipping the smoothing on real, noisy data. Use the LoG, or blur before applying a 3 × 3 kernel.
- Mixing sign conventions between the positive-centre and negative-centre kernels, which turns sharpening into blurring.
- Treating |∇²f| as edge strength. The Laplacian is zero at the edge itself; strength comes from the slope across the zero crossing or from the gradient.
- Comparing raw LoG responses across σ. Multiply by σ² first.
- Ignoring no-data and borders. A no-data value of 0 or −9999 next to valid pixels creates huge false responses; zero padding creates a false edge around the image.
Related Tools and Guides
Frequently Asked Questions
What does the Laplacian of an image measure?
It measures how much a pixel differs from the average of its neighbours. For the 4-neighbour kernel, ∇²f ≈ 4 × (mean of the four neighbours − f). It is zero in flat areas and on linear ramps, negative where a pixel is brighter than its surroundings (bright spots, the bright side of an edge) and positive where it is darker.
Why does a Laplacian kernel sum to zero?
Because the Laplacian of a constant is zero. If the weights summed to anything else, a uniform region would give a non-zero response. A zero sum also means the Laplacian ignores the average brightness of the image and responds only to its variations.
Why is the Laplacian zero exactly at an edge?
A blurred edge is an S-shaped transition. Its slope (first derivative) is largest in the middle, so the curvature (second derivative) changes sign there: positive on the dark side, negative on the bright side and zero at the inflection point. The zero crossing therefore marks the edge position.
What is the difference between the Laplacian and the Sobel operator?
Sobel estimates the first derivative (gradient) in x and y, giving edge strength and direction but requiring two kernels. The Laplacian is a single, rotation-invariant second-derivative operator that gives no direction, responds twice to thin lines and is more sensitive to noise. Gradient-based detectors such as Canny usually give cleaner edges; the Laplacian of Gaussian is preferred for blobs and zero-crossing contours.
Why is the Laplacian of Gaussian called the Mexican hat?
The negative of the LoG, −∇²G, has a positive central peak surrounded by a negative ring, like a sombrero seen in profile. The ring crosses zero at r = √2σ. The same centre-surround shape describes the receptive fields of retinal ganglion cells, which inspired Marr and Hildreth.
How is the Laplacian related to unsharp masking?
For small σ a Gaussian blur behaves like G * f ≈ f + (σ²/2)∇²f. Unsharp masking, g = f + c(f − G * f), is therefore approximately g = f − c(σ²/2)∇²f, which is Laplacian sharpening. Unsharp masking simply uses a smoother, less noise-sensitive estimate of the Laplacian.
Where else is the Laplacian used outside image processing?
It is the operator in the heat (diffusion) equation, in Laplace's and Poisson's equations for electrostatics, gravity and steady groundwater flow (∇²h = 0 in a homogeneous aquifer), and in the wave equation. The 4-neighbour kernel is the classic five-point finite-difference stencil. The graph Laplacian L = D − A extends it to networks and is used in spectral clustering and graph neural networks.
References
Marr, D., & Hildreth, E. (1980). Theory of edge detection. Proceedings of the Royal Society of London B, 207(1167), 187–217.
Gonzalez, R. C., & Woods, R. E. (2018). Digital Image Processing (4th ed.), Section 3.6 and Chapter 10. Pearson.
Lindeberg, T. (1998). Feature detection with automatic scale selection. International Journal of Computer Vision, 30(2), 79–116.
Lowe, D. G. (2004). Distinctive image features from scale-invariant keypoints. International Journal of Computer Vision, 60(2), 91–110.
Burt, P. J., & Adelson, E. H. (1983). The Laplacian pyramid as a compact image code. IEEE Transactions on Communications, 31(4), 532–540.
Canny, J. (1986). A computational approach to edge detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 8(6), 679–698.
LeVeque, R. J. (2007). Finite Difference Methods for Ordinary and Partial Differential Equations, Chapter 3 (the five-point Laplacian). SIAM.
Cite this article: Ghimire, B. (2026). Laplacian Filter Explained: Kernels, LoG, Zero Crossings & Edges. Engineers Views. https://engineersviews.com/blog/laplacian-filter-explained/