Talk:Gaussian blur

Linearly Separable
The Gaussian filter can be applied with a 2d mask, or two 1d masks in sequence. Is "Linearly Separable" really the proper term for this? "Sequenced Convolution" perhaps? —Preceding unsigned comment added by 82.46.170.107 (talk) 21:09, 25 April 2008 (UTC)
 * That's what separable convolution is. I've never heard of "sequenced convolution". —Ben FrantzDale (talk) 01:36, 26 April 2008 (UTC)


 * I've heard both "sequenced" and "separable" before, but you're right "separable convolution" seems to be the most widely used term. Surely it's not linearly separable though...

What does "Gaussian" mean?
I spent some time looking through the article to find what the term "Gaussian" means, and didn't find any answers. After some further googling I found that it is named after a man named Gauss(http://www.webmonkey.com/webmonkey/glossary/gaussian.html). I am surprised the introduction doesn't mention this, and assumes the reader knows (or doesn't care) what Gaussian actually means -- I looked up this article to discover that, and the entire Wiki article didn't help.

Additionally, does Gaussian always necessarily mean it relates in some way to Karl Friedrich Gauss? Perhaps that clarification is beyond the scope of this article, but surely the fact that Gaussion in this case refers to Karl Friedrich Gauss is not? —Preceding unsigned comment added by Abeall (talk • contribs) 18:55, 3 January 2008 (UTC)
 * "Gaussian" almost always refers to CF Gauss. I cleaned up the intro accordingly. —Ben FrantzDale (talk) 01:36, 26 April 2008 (UTC)

Radius
The page claims most programs use a radius of 6&sigma;+1. Won't this depend entirely on the bit depth? That is, to get "perfect" results you need a radius such that the value of the convolution kernel at that radius would round to zero in that bit depth? Actually, you might need to go further... I think the worst case is bluring a black circle with a white background. To find the result corresponding to the center of the circle you want to make sure your filter is large enough to get the correct value at the center of the circle in the current bit depth. I could work out the math, but either way, the optimum radius of the kernel will certainly be a function of bit depth. —Ben FrantzDale 15:14, 2 May 2006 (UTC)


 * The truncation boundary 6&sigma;+1 is rather arbitrary; see the article on scale-space implementation for a complementary description. Tpl 17:41, 9 July 2006 (UTC)

Out-of-focus lens
Image:Josefina with Bokeh.jpg - Try doing this in the GIMP.

Shouldn't it rather say something like "viewing through a translucent screen". According to my understanding the blur you get with an out of focus lens has a distribution that's close to even inside a projection of the iris and zero outside it. That doesn't look a lot like the bell curve. See bokeh. —Home Row Keysplurge 14:50, 10 May 2006 (UTC)
 * I think it depends on the lens. Mirror lenses, for example, are close to zero at the center, then go up and back down to zero as you go out, causing halos. Whether or not there's a lens with a Gaussian distribution, I have no idea. (unsigned by 212.9.28.123)
 * Well, mirror lenses naturally produce a shadow in the centre of the blur, but that's not the point. The point is, lens blur is not Gaussian, and a Gaussian blur doesn't look anything like a lens blur. (I don't even think it's physically possible to build a lens that creates a Gaussian blur.) —Home Row Keysplurge 10:27, 18 May 2006 (UTC)
 * I'm going to be bold and just change it. —Home Row Keysplurge 10:39, 18 May 2006 (UTC)


 * Regarding the example image saying "Try doing this with the GIMP.", from what I can tell this can't be done easily with just the GIMP right now, but it can be done with the GIMP and the help another program such as ImageJ to do a large arbitrary convolution. I took an image in GIMP, set the gamma very high, saved that, opened it in ImageJ, convolved it with a 41-pixel–diameter circular kernel (which took a while since it's a O(x·y·r2) operation), saved that result, opened it in the GIMP, reversed the gamma transformation (which was required to get just the bright spots to bloom into circles), then finally I overlayed the unblured version and masked the portion I wanted out of focus. I tweaked the results (adding noise, and a tiny bit of gaussian blur), but what I describe got me 90% of the way from the original to the final version shown here:
 * {| class="wikitable"


 * [[Image:Faux-bokeh-original.png|thumb|none|original]]
 * [[Image:Faux-bokeh-final.png|thumb|none|final]]
 * }
 * The python script I used to make the convolution kernel goes like this:

import math size = 41 mid = size/2 for x in range(0,size): for y in range(0, size): dist = math.sqrt(pow(x-mid,2)+pow(y-mid,2)) if dist < mid-0.5: print 1, elif dist > mid+0.5: print 0, else: print dist-(mid-0.5), print ""
 * 1) !/usr/bin/python
 * I was amazed how easy this was to do well. I added it as GIMP Bug #345845. —Ben FrantzDale 23:06, 24 June 2006 (UTC)


 * As pointed out to me on that bug, there is a GIMP plugin to do this. —Ben FrantzDale 01:16, 26 June 2006 (UTC)

The formulae

 * $$G(r) = \frac{1}{\sqrt{2\pi} \sigma} e^{-r^2/(2 \sigma^2)}$$

or


 * $$G(u,v) = \frac{1}{2\pi \sigma^2} e^{-(u^2 + v^2)/(2 \sigma^2)}$$

Why has the square root disappeared from the second formula, and why has a $$\sigma^2$$ appeared?

We're told that $$r^2 = u^2 + v^2$$ so why wasn't that substitution the only difference?

I ask not because I think it's wrong, but because I'm trying to understand the formula before I use it in a program I'm writing.

Edited to add: for example see http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node99.html - this page shows this formula:


 * $$G(i,j) = \frac{1}{\sqrt{2\pi \sigma^2}} exp(\frac{-(i^2 + j^2)}{(2 \sigma^2)})$$

It looks to me as if the square root should be in the second formula above, and that it should extend over the sigma squared (and perhaps the first formula should extend it too and square the sigma for consistency?).

Can anyone clear this up for me?


 * It should be clarified that G(r) is a Gaussian distribution in 1 dimension. G(u,v) is simply the result of G(u,v) = G(u) * G(v) which is the correct way to use the Gaussian distribution in 2 dimensions. If you use G(r) with $$r^2 = u^2 + v^2$$ then the result of the integral in both dimensions is no longer 1. The formula on the reference link you found can be proved to be incorrect by counter-example: we use i=j=0 (which is the center of the matrix) G(0,0) = 0.398942 according to the given formula. But the value in the center of the matrix is 159/1003 = 0.158524 ... surprisingly this is very close to 1 / (2 * Pi). So in my opinion the forumlas in the article G(r) is correct in 1 dimension and G(u,v) is correct in 2 dimensions. So the statement $$r^2 = u^2 + v^2$$ should be removed.


 * Okay, how about this as a proposed replacement? I've replaced r with d in the one-dimensional example and taken out the bit about the radius.


 * ...The equation of Gaussian distribution in one dimension is


 * $$G(d) = \frac{1}{\sqrt{2\pi} \sigma} e^{-d^2/(2 \sigma^2)}$$


 * or, in two dimensions,


 * $$G(u,v) = \frac{1}{2\pi \sigma^2} e^{-(u^2 + v^2)/(2 \sigma^2)}$$


 * where σ is the standard deviation of the Gaussian distribution...


 * What do you think? David 11:30, 22 June 2006 (UTC)
 * Surely it is approximately equal, and not equal therefore? 129.78.220.7 05:28, 18 July 2007 (UTC)

I modified the equations to the equations that actually fit the example matrix. However after some more research I found that both the current equations and the equations I chagned to are used commonly. Therefore I reverted my changes so now the example matrix doesn't match up with the presented equations. Rune Hunter (talk) 05:27, 11 June 2008 (UTC)

With no doubt, the convolution of the signal by a gaussian kernel should preserve the total energy of the signal which is only possible if the integral of the function on the whole domain is equal to one. Hence, as the 2D integral of the non-normalized gaussian kernel is expressed as $$I = \int_{-\infty}^{+\infty} \int_{-\infty}^{+\infty} e^{-(x^2 + y^2)/(2 \sigma^2)} d(x) d(y)$$, we have $$I = \int_{-\infty}^{+\infty} \int_{-\infty}^{+\infty} e^{-x^2/(2 \sigma^2)}  e^{-y^2/(2 \sigma^2)} d(x) d(y)$$, therefore $$I = \int_{-\infty}^{+\infty} e^{-x^2/(2 \sigma^2)} d(x) \int_{-\infty}^{+\infty} e^{-y^2/(2 \sigma^2)} d(y)$$. As the integral of the non-normalized 1D gaussian is $$\sqrt{2\pi} \sigma$$, the 2D integral is equal to $$2\pi \sigma^2$$. Therefore the normalized 2D gaussian equation must be $$G(x,y) = \frac{1}{2\pi \sigma^2} e^{-(x^2 + y^2)/(2 \sigma^2)}$$. This is of course generalizable to nD dimensions: $$G(\mathbf{v}) = \frac{1}{(\sqrt{2\pi} \sigma)^n} e^{-(\mathbf{v}^\text{T} \mathbf{v})/(2 \sigma^2)}$$ where $$\mathbf{v}$$ is a vector of $$ n$$ dimensions. —Preceding unsigned comment added by 130.104.224.111 (talk) 09:59, 11 June 2008 (UTC)

Yes, this is similar to what was previously in this article and the formula should probably be reverted. Side note... The Fourier transform of a Gaussian is another Gaussian, but I have not been able to find a good resource that defines what this transformed Gaussian is in terms of n dimensions, and the constant needed to preserve the signal properly; if anyone feels up to adding that, it would be appreciated. The relevance is the topic of how Gaussian blurs work in reciprocal space. —Preceding unsigned comment added by 137.131.204.136 (talk) 00:31, 21 January 2009 (UTC)

Note removed from article

 * ''(Note 12 July 2006 - xShin)
 * ''The matrix dimension would be better calculated in this manner $$n=ceil(3\sigma)$$ Kernel Size = $$(2n+1) \times (2n+1)$$.
 * ''(End of Note 12 July 2006 - xShin)
 * I removed that note from the article, since it seemed to belong here. Luna Santin 07:01, 12 July 2006 (UTC)

Radius again
The article mentions the radius as if it was a well-known property, but nowhere is it explained what the blur radius is. Sam Hocevar (talk) 09:12, 28 July 2008 (UTC)
 * I looked at The Gimp’s source code, and their implementation of Gaussian blur uses the following sigma/radius relationship:
 * $$\sigma = \frac{r + 1}{\sqrt{2\log{255}}}$$
 * This is pretty close to r/3.
 * In ImageMagick, on the other hand, σ is the user-provided parameter, not r. The “radius” can be user-provided separately and is simply an indication for the kernel size to use (see GetOptimalKernelWidth2D). Sam Hocevar (talk) 15:18, 29 July 2008 (UTC)
 * Good point. A normal distribution doesn't have compact support, so there's no finite radius. Of course, if implemented as a convolution (rather than in the frequency domain), you want as small a kernel as possible, so you pick a finite kernel radius. The article should explain this. It looks like Gimp's version is designed for 8-bit color... inverting it you get
 * $$r = \sigma \cdot \sqrt{2\log 255} - 1$$
 * Without plugging in numbers, I'm guessing that kernel size is sufficient for a delta function (one pixel of brightness 255 surrounded by black) to convolve to get exactly what you would expect for an infinite kernel size. Although I wonder if the same can be said of two or more adjacent white pixels surrounded by black... —Ben FrantzDale (talk) 00:37, 30 July 2008 (UTC)

Relation to Gaussian filter
Something should probably done to connect this article to the gaussian filter one, especially since the subjects are so closely related and there's already some duplication of content. -Roger (talk) 18:36, 24 February 2009 (UTC)

I've come to the discussion page after seeing the merge proposal with Gaussian filter and reviewing the two articles. I would vote against, pretty strongly, for these reasons: That's my feedback, anyway. 88.96.159.86 (talk) 10:50, 18 February 2011 (UTC)
 * I wanted to know specifically about Gaussian blur, and compare it with Motion Blur (etc). The article gave me that quite clearly.  I'd have probably given-up and surfed off elsewhere to find the information if I'd been confronted with the information on "Gaussian Filter"... it's technical, it's not what I was looking for, and I didn't understand it.
 * There are 9 Gaussian this-that-and-the-others in Wikipedia. I don't find a particularly strong relationship between these two articles.
 * The subject areas are initially declared as different anyway:
 * Gaussian filter starts: "In electronics and signal processing,..."
 * Gaussian blur says: "It is a widely used effect in graphics software"
 * Gaussian function (mentioned in the intro to Gaussian Blur) starts: "In mathematics..."

Halos
Would anyone address those issues using Gaussaian Filters? --Royi A (talk) 12:39, 16 October 2009 (UTC)

computation time
"Applying multiple, successive gaussian blurs to an image has the same effect as applying a single, larger gaussian blur, whose radius is the square root of the sum of the squares of the blur radii that were actually applied. For example, applying successive gaussian blurs with radii of 6 and 8 gives the same results as applying a single gaussian blur of radius 10, since . Because of this relationship, processing time cannot be saved by simulating a gaussian blur with successive, smaller blurs — the time required will be at least as great as performing the single large blur."

I don't believe this is accurate, referencing gpu massively parallel applications and smaller mask windows — Preceding unsigned comment added by 70.208.73.107 (talk) 17:42, 16 November 2013 (UTC)

External links modified
Hello fellow Wikipedians,

I have just modified one external link on Gaussian blur. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
 * Added archive https://web.archive.org/web/20100310103512/http://holiday.snrk.de/SnarkSearch.cgi to http://holiday.snrk.de/SnarkSearch.cgi

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

Cheers.— InternetArchiveBot  (Report bug) 21:07, 11 October 2017 (UTC)

Physical basis for Gaussian blurs
While the Gaussian function is very important in statistics, does the same hold true for optics? The Gaussian blur seems to be the go-to blur method, preferred over more naïve digital methods for its supposedly appealing retention of edges, but this alone doesn't say much about its objective basis. I find it interesting that the similar Cauchy function never gets used for this purpose, despite it also offering seemingly natural-looking blurs with long tails yielding an oneric aesthetic. I guess the question boils down to how close the Gaussian function resembles the behaviour of blurring incurred by the interaction of light with real materials and the human eye. A notable case is how it poorly represents the bokeh blur of out-of-focus camera shots. 212.60.107.203 (talk) 09:21, 13 June 2019 (UTC)