ArticleslgStudy

computer science

Difference of Gaussians

Difference of Gaussians is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Difference of Gaussians rather than just read about it. In short: In imaging science, difference of Gaussians (DoG) is a feature enhancement algorithm that involves the subtraction of one Gaussian blurred version of an original image from another, less blurred version of the original. In the simple case of grayscale images, the blurred images are obtained by convolving the original grayscale images with Gaussian kernels having differing width (standard deviations).

Difference of Gaussians — main illustration
Difference of Gaussians — illustration

Key takeaways

  • Difference of Gaussians belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Difference of Gaussians to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Difference of Gaussians from memory before moving on to harder problems.

Reference excerpt

In imaging science, difference of Gaussians (DoG) is a feature enhancement algorithm that involves the subtraction of one Gaussian blurred version of an original image from another, less blurred version of the original. In the simple case of grayscale images, the blurred images are obtained by convolving the original grayscale images with Gaussian kernels having differing width (standard deviations). Blurring an image using a Gaussian kernel suppresses only high-frequency spatial information. Subtracting one image from the other preserves spatial information that lies between the range of frequencies that are preserved in the two blurred images. Thus, the DoG is a spatial band-pass filter that attenuates frequencies in the original grayscale image that are far from the band center.

Formulation

Let Φt:ℝn→ℝ denote the radial Gaussian function Φt(x)=𝒩(x|0,t) with mean 0 and variance t, i.e., the multivariate Gaussian function Φt(x)=𝒩(x|0,tI) with mean 0 and covariance tI. More explicitly, we have

Φt(x)=1(2πt)n/2e−‖x‖22t. The difference of Gaussians with variances t1<t2 is the kernel function

Kt1,t2=Φt1−Φt2 obtained by subtracting the higher-variance Gaussian from the lower-variance Gaussian. The difference of Gaussian operator is the convolutional operator associated with this kernel function. So given an n-dimensional grayscale image I:ℝn→ℝ, the difference of Gaussians of the image I is the n-dimensional image

I∗Kt1,t2=I∗(Φt1−Φt2)=I∗Φt1−I∗Φt2. Because convolution is bilinear, convolving against the difference of Gaussians is equivalent to applying two different Gaussian blurs and then taking the difference. In practice, this is faster because Gaussian blur is a separable filter.

Approximation The difference of Gaussians can be thought of as an approximation of the Mexican hat kernel function used for the Laplacian of the Gaussian operator. The key observation is that the family of Gaussians Φt is the fundamental solution of the heat equation

∂tΦt(x)=12ΔΦt(x). The left-hand side can be approximated by the difference quotient

Φt+δt(x)−Φt(x)δt=1δtKt+δt,t(x). Meanwhile, the right-hand side is precisely the Laplacian of the Gaussian function. Note that the Laplacian of the Gaussian can be used as a filter to produce a Gaussian blur of the Laplacian of the image because I∗ΔΦt=ΔI∗Φt by standard properties of convolution. The relationship between the difference of Gaussians operator and the Laplacian of the Gaussian operator is explained further in Appendix A in Lindeberg (2015).

Details and applications

As a feature enhancement algorithm, the difference of Gaussians can be utilized to increase the visibility of edges and other detail present in a digital image. A wide variety of alternative edge sharpening filters operate by enhancing high frequency detail, but because random noise also has a high spatial frequency, many of these sharpening filters tend to enhance noise, which can be an undesirable artifact. The difference of Gaussians algorithm removes high frequency detail that often includes random noise, rendering this approach one of the most suitable for processing images with a high degree of noise. A major drawback to application of the algorithm is an inherent reduction in overall image contrast produced by the operation. When utilized for image enhancement, the difference of Gaussians algorithm is typically applied when the size ratio of kernel (2) to kernel (1) is 4:1 or 5:1. In the example images, the sizes of the Gaussian kernels employed to smooth the sample image were 10 pixels and 5 pixels. The algorithm can also be used to obtain an approximation of the Laplacian of Gaussian when the ratio of size 2 to size 1 is roughly equal to 1.6. The Laplacian of Gaussian is useful for detecting edges that appear at various image scales or degrees of image focus. The exact values of sizes of the two kernels that are used to approximate the Laplacian of Gaussian will determine the scale of the difference image, which may appear blurry as a result. Differences of Gaussians have also been used for blob detection in the scale-invariant feature transform (SIFT). In fact, the DoG as the difference of two Multivariate normal distribution has always a total null sum and convolving it with a uniform signal generates no response. It approximates well a second derivate of Gaussian (Laplacian of Gaussian) with K~1.6 and the receptive fields of ganglion cells in the retina with K~5. It may easily be used in recursive schemes and is used as an operator in real-time algorithms for blob detection and automatic scale selection.

More information In its operation, the difference of Gaussians algorithm is believed to mimic how neural processing in the retina of the eye extracts details from images destined for transmission to the brain.

See also Marr–Hildreth algorithm Treatment of the difference of Gaussians approach in blob detection. Blob detection Gaussian pyramid Scale space

References

Further reading Notes by Melisa Durmuş on Edge Detection and Gaussian related mathematics from the University of Edinburgh.

Illustrations

Difference of Gaussians: Example before difference of Gaussians
Example before difference of Gaussians
Difference of Gaussians: After difference of Gaussians filtering in black and white
After difference of Gaussians filtering in black and white

Worked examples

Example 1 — a first encounter with Difference of Gaussians

Start with the simplest possible case. Write down what Difference of Gaussians claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Difference of Gaussians before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Difference of Gaussians ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Difference of Gaussians

In research
Difference of Gaussians appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Difference of Gaussians in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Difference of Gaussians is common in secondary-school and first-year university syllabi. It links to neighbouring topics Continuous wavelets, Feature detection (computer vision), so understanding it makes those chapters shorter.
In everyday life
Look for Difference of Gaussians outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Difference of Gaussians” →

How to study Difference of Gaussians in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Difference of Gaussians means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Difference of Gaussians out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Difference of Gaussians in simple terms?

In imaging science, difference of Gaussians (DoG) is a feature enhancement algorithm that involves the subtraction of one Gaussian blurred version of an original image from another, less blurred version of the original. In the simple case of grayscale images, the blurred images are obtained by conv…

Why does Difference of Gaussians matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Difference of Gaussians?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Difference of Gaussians.

Tags

  • Continuous wavelets
  • Feature detection (computer vision)

Keep exploring