Need help with gaussian blur, or any type of blur..

Started by
6 comments, last by joshualimm 18 years, 6 months ago
Hi. I'm fairly new to filter and blurring algorithm, so I'm kinda lost with the many threads here about blurring an image (in real time). Therefore, I's hoping if someone can recommend me any articles on the topic (in layman's terms), or perhaps show me an example with a simple function. Have been to gamasutra (glow effect) and wikipedia (for the gaussian blur's function), but I've no idea how to implement them. I've got lots of questions in mind, like what's a kernel? How do use it? Can I just divide an image into samples, and average them? What can I do to improve the speed? I've read many replies around here that suggests the use of shaders. That's why I'm posting here, because I'm trying to learn how to implement this function regardless of API (or hardware). Just a simple step-by-step tute to blur an image would be most helpful! Please help, and thanks!
Advertisement
The GIMP has a gaussian blur plugin. It's open source so you can look at the source for that.

Also, the writing a GIMP plugin tutorial actually implements a blur function, that is here.
Hmm, the Gimp is a good start, but not for real-time ^^
Well, I think I've read somewhere that you could simply render your scene to a texture (search for "render to texture") then downsample it (i.e. resize it at half or less its original size, or set your texture to automatically generate mimaps) and use it as if it were of the original size. The hardware texture filtering will smooth the result, giving a "not so ugly" blur ^^

(after a quick search, I found that method in a gamasutra article, probably the one you've read ^^)

That's the only way I can think of if you want "to implement this function regardless of API" ^^
"regardless of API (or hardware)"

Render to Texture hardly fits this requirement.

Paic, I was suggesting Joshua look at the GIMP source for an implementation of blurring (just what he asked for), not use the GIMP to do it with...
Yep, I understood that trippytarka ^^ But the gimp uses algorithms which are not designed for realtime. And looking at sources of a big project like Gimp is really not the simplest way to learn how to implement a bluring algorithm.

And I didn't say "don't look at gimp". Just that it wasn't designed for real-time (joshua said "in real time" ^^) So don't take it personaly ^^
I posted on this thread very fast "almost gaussian" blur (it looks gaussian, but is quite far from it). Blur's are always done using some sort of filter. I suggest you study a little bit about convolution, FIR and IIR filters (my blur is a very simple IIR-filter).
The GIMPs blur code is hardly big or complicated. Due to the plugin architecture, learning how to implement blur from the available code is in fact very simple.
hi guys! Thanks for the help and suggestions!!

trippytarka:
Thanks for the gimp tip. Have been checking the site out. Real time or not (though I'd prefer real time. :P), I'm still thankful. After all, I do want to get familiar with image manipulation.

paic:
Hehe, I've managed to "render to texture" alright, but by stretching it to fit the screen, I do get jagged edges. And yeah, have been to Gamasutra as well, and have checked out both the Glow and Fast Blur articles. Unfortunate for me, I'm not at all familiar with shaders yet, nor am I good at reading technical papers (ok, fine, punch me :D). That's why I'm looking for a simple example that I'll be able to relate to. (odd enough, I learn faster through reading source code. Boy am I gonna be in trouble if my lecturer reads this)


Winograd:
Thanks! Now I'll have some keywords to plug into googles. :D While I can't really understand your code (yet), I'm sure it'll come in handy as I combine it with the more theoretical articles I find (on IIR, FIR, Convolution). Will also check out Gimp's IIR (?) Gaussian Blur later.

Yawn, just had to come back to post a few thank you's. :) Now gtg to bed. Once again, thanks for the tips/help!

This topic is closed to new replies.

Advertisement