# Can you help me make an Gaussian Blur filter using C

This topic is 1092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

The gaussian Blur can be make using this function:

http://imgur.com/1ilxU5k

But I am a newbie and I don't know how to make it on C, can anyone help me please :(

##### Share on other sites

I'd post some code but my stuff is optimized so it wouldn't make any sense. I'm sure there's examples online (and DirectX SDK) for this but here's the over view in a nut shell.

First you want to compute a bell curve based on the number of samples that you want to use for your blur. You can use hard coded numbers for this but computing your own bell curve will allow you fine tune it to your needs. All we care about is half the bell curve because this is your target pixel and the number of samples taken. These values are your weights. Target pixel plus half the number of samples. We can now reused these samples for the other side of the target pixel. X = target pixel.

+++++X+++++ = 1.0

In the example above, there is 11 weights. If you were to add them all up, they would equal 1.0. You use the same array of weights to do the horizontal and vertical blur pass. At this point you simply multiply the sampled pixels by their respective weights to calculate the new color of the target pixel.

As stated above, this is a two step process and you'll need one additional buffer to complete the process. This assumes you're using a back buffer. Otherwise you'll need two buffers depending on how you are implementing it.

First pass - horizontal: Sample the values from the back buffer and write the new pixel value to the extra buffer.

Second pass - vertical: Sample the values from the extra buffer and write the new pixel value to the back buffer.

That's it in a nut shell. There's optimizations you can do like use two smaller buffers to do the blurring. Scale it down to a smaller buffer, blur between the two buffers, scale back up to the original size.

Edited by GameCodingNinja

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633735
• Total Posts
3013594
×