Gaussian filter confusion

Started by
4 comments, last by lipsryme 10 years, 7 months ago

I'm a little confused about the gaussian filter function which can be found on several sources.

What's confusing to me is that I've found at least 3 different equations for the same thing...

I've marked the differences in red color.

Wikipedia lists it as: (http://en.wikipedia.org/wiki/Gaussian_filter)

g(x) = (1 / (sqrt(2 * PI) * rho)) * exp(-(x*x) / (2 * (rho * rho)))

While the one found in Real-Time-Rendering, Third Edition defines it as:

g(x) = (1 / (sqrt(2 * PI) * rho * rho)) * exp(-(x*x) / (2 * (rho * rho)))

And finally the code that I've got from one of MJP's samples:

g(x) = (1 / (sqrt(2 * PI * rho * rho))) * exp(-(x*x) / (2 * (rho * rho)))

What am I missing here ?

Advertisement

Assuming that you meant to divide by rho instead of multiplying by rho at all places, as indicated by the Wikipedia link, the first and third are identical, and the second is different only by a scale factor. I'd say the first and third ones are the "correct" ones as they have unit scaling, but if you disregard the scaling then the second one is no less correct than the other two.

Not sure what you mean by "Assuming that you meant to divide by rho instead of multiplying by rho at all places". What scaling are you talking about ?

RTR defines it as: http://d.pr/i/3Dsg

Where is this squared rho coming from ?

Hmm, I'd imagine the RTR is a typo because typically you don't want to scale and you want to be normalized to 1 when you integrate over the domain -\inf to \inf. That's what the term out in the front is for. I don't have the book on me at the moment to see in context what they are talking about.

-= Dave

Graphics Programmer - Ready At Dawn Studios

The σ symbol in that equation is sigma, not rho, but never mind that. If you look at the equation, σ2 is in the denominator so you need to divide by σ, not multiply by σ (or rho; ρ) as you have in your original posts. Basically, your original post stated 1/sqrt(2π)*σ, where the correct equation in 1/(sqrt(2π)*σ). Likewise in the exponent, the correct equation is exp(-x*x/(2*σ*σ)). Note the parentheses to get the factors, dividends and the divisors correct.

Scaling refers to the linear scaling perform by the filter. If the filter has a scaling by for example 2, it means that the values of the signal is filtered but also scaled by 2 in amplitude. Your first and third equations does not have any additional scaling as the second equation has. Your second filter is scaled by 1/σ, which means that if σ=0.25, then the filtered signal is four times larger than the input signal apart from the actual filtering.

Ah yes sorry I keep confusing these symbols names smile.png (maybe I should just call it the standard deviation rolleyes.gif ) and yes it seems I've made some mistakes in the parentheses (fixed it now) but that scaling factor is basically what I'm confused about the reason why it's in there.

This topic is closed to new replies.

Advertisement