# Talk:Gaussian blur

WikiProject Photography (Rated B-class, Mid-importance)
This article is within the scope of WikiProject Photography, a collaborative effort to improve the coverage of photography on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
B  This article has been rated as B-Class on the project's quality scale.
Mid  This article has been rated as Mid-importance on the project's importance scale.

## 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 (talkcontribs) 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)

The page claims most programs use a radius of 6σ+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σ+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:
 original final
The python script I used to make the convolution kernel goes like this:
#!/usr/bin/python
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 ""

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[1]. —Ben FrantzDale 01:16, 26 June 2006 (UTC)

## The formulae

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

or

${\displaystyle 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 ${\displaystyle \sigma ^{2}}$ appeared?

We're told that ${\displaystyle 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.

${\displaystyle 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 ${\displaystyle 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 ${\displaystyle r^{2}=u^{2}+v^{2}}$ should be removed.

...The equation of Gaussian distribution in one dimension is
${\displaystyle G(d)={\frac {1}{{\sqrt {2\pi }}\sigma }}e^{-d^{2}/(2\sigma ^{2})}}$
or, in two dimensions,
${\displaystyle 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 ${\displaystyle I=\int _{-\infty }^{+\infty }\int _{-\infty }^{+\infty }e^{-(x^{2}+y^{2})/(2\sigma ^{2})}d(x)d(y)}$, we have ${\displaystyle I=\int _{-\infty }^{+\infty }\int _{-\infty }^{+\infty }e^{-x^{2}/(2\sigma ^{2})}e^{-y^{2}/(2\sigma ^{2})}d(x)d(y)}$, therefore ${\displaystyle 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 ${\displaystyle {\sqrt {2\pi }}\sigma }$, the 2D integral is equal to ${\displaystyle 2\pi \sigma ^{2}}$. Therefore the normalized 2D gaussian equation must be ${\displaystyle 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: ${\displaystyle G(\mathbf {v} )={\frac {1}{({\sqrt {2\pi }}\sigma )^{n}}}e^{-(\mathbf {v} ^{\text{T}}\mathbf {v} )/(2\sigma ^{2})}}$ where ${\displaystyle \mathbf {v} }$ is a vector of ${\displaystyle 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 ${\displaystyle n=ceil(3\sigma )}$ Kernel Size = ${\displaystyle (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)

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:
${\displaystyle \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
${\displaystyle 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:

• 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..."

That's my feedback, anyway. 88.96.159.86 (talk) 10:50, 18 February 2011 (UTC)

## 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)