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:

StagePurpose
Gaussian smoothingReduce rapid noise changes
LaplacianProduce positive and negative responses around an intensity transition
Zero-crossing detectionPlace 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

  1. Convolve the image with a Gaussian smoothing mask
  2. Convolve the smoothed image with the second-derivative mask

Method 2: One Combined LoG Pass

  1. Combine the two masks with convolution
  2. 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:

ColumnOriginal valueSmoothed 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:

SymbolMeaning
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:

  1. Take its centred coordinates
  2. Calculate
  3. Substitute into the LoG equation
  4. 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

MethodDerivative evidenceEdge decisionMain result
Image Gradient and Edge DetectionFirst derivativeLarge gradient magnitudeSimple candidate edge pixels
LoGSmoothed second derivativeZero crossingCleaner edge localization
Canny Edge DetectorSmoothed first derivativeThinned maxima with hysteresisThin 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.