# Gaussian based Weights

## Recommended Posts

Hi.  I was studying the Bloom tutorial on learnopengl.com.

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!

This might help:

##### Share on other sites

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';
}
}


## Create an account

Register a new account

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632632
• Total Posts
3007524
• ### Who's Online (See full list)

There are no registered users currently online

×