The Laplacian of Gaussian, or LoG, is an edge-detection filter. It smooths the image, measures a second derivative, and places the edge where the filtered response changes sign.
Main idea
Prewitt and Sobel select large first-derivative responses. LoG selects zero crossings of a smoothed second-derivative response.
Why LoG Is Needed
Prewitt and Sobel estimate the first derivative of an image. Their raw edge responses can contain noise and several neighbouring responses around one boundary.
LoG adds Gaussian smoothing before the second derivative is measured:
| Stage | Purpose |
|---|---|
| Gaussian smoothing | Reduce rapid noise changes |
| Laplacian | Produce positive and negative responses around an intensity transition |
| Zero-crossing detection | Place the edge where the response changes sign |
Complete LoG Operation
flowchart LR I["Input image"] --> G["Gaussian smoothing<br/>reduce noise"] G --> L["Laplacian<br/>second derivative"] L --> R["Positive and negative<br/>response lobes"] R --> Z["Find the<br/>zero crossing"] Z --> E["Edge position"]

The peaks are not the edge position
The positive and negative peaks show the two sides of the response. The zero crossing between them gives the edge position.
Two Equivalent Implementations
LoG can be applied in two ways.
Method 1: Two Filter Passes
- Convolve the image with a Gaussian smoothing mask
- Convolve the smoothed image with the second-derivative mask
Method 2: One Combined LoG Pass
- Combine the two masks with convolution
- Convolve the image with the combined mask
The two discrete forms are equivalent because convolution is associative:
Here, means two-dimensional convolution. It does not mean ordinary matrix multiplication or element-by-element multiplication.
Worked Image Example
Consider this image:
The image changes from dark pixels with value to bright pixels with value . The vertical edge is between columns and .
Pass 1: Gaussian Smoothing
Use this Gaussian mask:
At an interior position in column , the image neighbourhood is:
The smoothed value is:
The corresponding values near the edge become:
| Column | Original value | Smoothed value |
|---|---|---|
The original sharp transition:
becomes the smoother transition:
Pass 2: Second Derivative
Use this positive-centre second-derivative mask:
At column , the smoothed neighbourhood is:
Therefore:
At column :
Find the Edge
The response changes sign between columns and :
The zero crossing is therefore between these columns. This is the edge position.
Combining the Two Masks
The Gaussian mask and second-derivative mask are combined by two-dimensional convolution:
For the two masks in the worked example:
Full convolution combines two masks into a mask:
Applying this combined mask once gives the same operation as applying the two masks in sequence.
How the LoG Equation Creates a Mask
Using the inverted Gaussian convention:

Its two-dimensional Laplacian is:

The continuous equation gives the same two implementation choices:
| Symbol | Meaning |
|---|---|
| Centred coordinates inside the small filter mask | |
| Radial distance from the filter centre | |
| Gaussian scale | |
| Inverted Gaussian response | |
| LoG mask coefficient at that position |
The symbols and are offsets inside the small filter mask. They are not the absolute coordinates of an image pixel.
For a mask:
For a mask:
For each mask cell:
- Take its centred coordinates
- Calculate
- Substitute into the LoG equation
- Store the result as the coefficient of that mask cell
This process creates the mask once. The same mask then slides across all image positions.
The continuous LoG response has:
- A positive central lobe
- Negative side lobes
- A zero-crossing ring at
- A negative ring near
Sign convention
The inverted Gaussian gives the LoG a positive centre. Reversing every mask sign exchanges the positive and negative lobes, but the zero-crossing position stays the same. Canny uses a positive Gaussian convention.
Effect of
| Choice of | Main effect |
|---|---|
| Smaller | Detects finer changes and retains more noise |
| Larger | Smooths more strongly and detects structures at a coarser scale |
LoG is less sensitive to noise than an unsmoothed second derivative. It still requires a suitable scale and a suitable rule for accepting zero crossings.
LoG Compared with Other Edge Detectors

| Method | Derivative evidence | Edge decision | Main result |
|---|---|---|---|
| Image Gradient and Edge Detection | First derivative | Large gradient magnitude | Simple candidate edge pixels |
| LoG | Smoothed second derivative | Zero crossing | Cleaner edge localization |
| Canny Edge Detector | Smoothed first derivative | Thinned maxima with hysteresis | Thin and connected edge pixels |
What to remember
LoG is a filter. Build or select one small LoG mask, slide it across the image, and detect sign changes in the output. The zero crossing, not the response peak, gives the edge position.