🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Gaussian based Weights

Started by
2 comments, last by alvaro 6 years, 6 months ago

Hi.  I was studying the Bloom tutorial on learnopengl.com.
https://learnopengl.com/#!Advanced-Lighting/Bloom

I understand the benefits of using a Gaussian blur for achieving a Bloom effect.  I understand that the author of this tutorial is using the gaussian values as weights which are used to determine how much neighboring pixels should affect the current pixel when blurred.  In this tutorial, the author chooses to use the following weights,

0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216

Where 0.227027 + (0.1945946*2.0) + (0.1216216 * 2.0) + (0.054054 * 2.0) + (0.016216 *2.0) comes out to about 1.  The author chooses to same 4 samples to the left and right of the current pixel for a total sample count of 9 per axis.  All that makes sense but what I don't understand is how to calculate the weights myself.  For example, lets say I wanted a sample count of some arbitrary number like 5.

With a sample count of 5, the formula would then need to be A + (B * 2.0) + (C * 2.0) + (D * 2.0) + (E * 2.0) = 1
What I want to do is figure out how to calculate the wights, A,B,C,D, and E given the sample count.  Thanks!

xdpixel.com - Practical Computer Graphics

Advertisement

This might help:

http://dev.theomader.com/gaussian-kernel-calculator/

Here's a short C++11 program that roughly produces the same numbers:


	#include <cmath>
	#include <iostream>
	 
	int main() {
	  double sigma = 1.75;
	  int N = 4;
	  
	  double total = std::erf((N+.5) / (std::sqrt(2.0) * sigma)) - std::erf((-N-.5) / (std::sqrt(2.0) * sigma));
	  for (int i = -N; i <= +N; ++i) {
	    std::cout << (std::erf((i+.5) / (std::sqrt(2.0) * sigma)) - std::erf((i-.5) / (std::sqrt(2.0) * sigma))) / total << '\n';
	  }
	}
	

This topic is closed to new replies.

Advertisement