Skip to content
ExtendedSource checked

Difference of Gaussians

Highlights image structures by subtracting two Gaussian-blurred versions at different scales.

Quick Facts

Compact metadata for implementation and discovery.

Category
Image Processing
Difficulty
Intermediate
Family
Scale-Space Filtering
Tier
Extended
Status
Verified
Review
Source Checked
Sources
2
Formulas
1
Relationships
1
Code example
Ready
Visualization
Ready

Overview

Difference of Gaussians approximates scale-selective edge or blob detection by comparing a lightly blurred image with a more heavily blurred one.

Core Concepts

Gaussian scaleimage subtractionscale spaceblob response

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(pixels)

Average

O(pixels * kernel_size)

Worst

O(pixels * kernel_size)

Space

O(pixels)

When to Use

  • Use when features at a chosen scale should stand out from smoother background content.
  • Use when blob detection is a central requirement.

When Not to Use

  • Avoid when raw edges are needed without scale filtering.
  • Avoid when lighting, noise, or scale changes dominate the image signal.

What It Does

  • Blurs the image at two scales
  • Subtracts the blurred images
  • Highlights scale-dependent changes

Use Cases

  • Blob detection
  • Edge enhancement
  • Feature detection preprocessing

Inputs

  • Image
  • Two Gaussian blur scales

Outputs

  • Difference image

Key Formulas (1)

DoG response

DoG = GaussianBlur(image, sigma1) − GaussianBlur(image, sigma2)
DoG = GaussianBlur(image, sigma1) - GaussianBlur(image, sigma2)

Compares image structure visible at two blur scales.

Pseudocode

  1. 1.Blur the image with a small sigma
  2. 2.Blur the image with a larger sigma
  3. 3.Subtract the second blurred image from the first
  4. 4.Optionally threshold or normalize the result

Canonical Example

Input
image has small bright spot, sigma1 = 1, sigma2 = 3
Output
spot appears strongly in difference image
Explanation
The small structure survives light blur more than heavy blur.

Implementation Notes

  • Reuse separable Gaussian blur for both scales to keep the operation efficient.
  • Start with grayscale or single-channel tests before applying the method to full images.
  • Keep a tiny example with expected output beside the implementation.

Common Pitfalls

  • Using nearly identical blur scales produces a weak noisy response.
  • Padding, threshold, and color-space choices can change the result dramatically.
  • Not defining boundary, empty, or degenerate inputs before implementation.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show fine details suppressed differently at two blur scales, then emphasized by subtraction.

Difference of Gaussians mechanism walkthrough step 1 of 4
Step 1 of 4: Blur the image with a small sigma
image-kernel

Notes

The choice of sigma values controls which structures are emphasized.

Sources (2)

What each reference supports for this entry.

Computer Vision: Algorithms and Applications

Book

Computer-vision reference supporting Difference of Gaussians feature extraction, image registration, segmentation, or multiscale image-analysis workflow.

Open source

Digital Image Processing

Book

Image-processing textbook support for Difference of Gaussians filtering, morphology, segmentation, restoration, or connected-component behavior.

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Difference of Gaussians subtracts two Gaussian-blurred images at different scales.

Tags

Image ProcessingFilteringEdge DetectionSmoothing