Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: psygate on November 03, 2006

Title: Blurring
Post by: psygate on November 03, 2006
Hi,

I havent written anything since two months or so (because I had some things to do) but I need your help once again!  ;D

Could you tell me how to do a blur? I mean, not this simple Middle-Color, in which you just add all points up and divide them by thier number, I mean something like gaussian, radial and movement blur!

Could someone help me?
Title: Re: Blurring
Post by: slinks on November 03, 2006
No idea, but you're in the wrong section mate.
Title: Re: Blurring
Post by: Jim on November 03, 2006
Hi Psygate - I moved the topic to this coding forum.

All blurs by definition are just adding up neighbouring colour values (in space, or in time) and averaging them out.  The different kinds of blur you mention are made by how you define neighbouring.  What kind of effect would you like to achieve exactly?

Jim
Title: Re: Blurring
Post by: psygate on November 04, 2006
I would be really interessted in radial blur. It's the only effect I could work out on my own... (radial blur fromt eh center and around, you know, there are towo options in photoshop how to blur with radial blur)
Title: Re: Blurring
Post by: mind on November 05, 2006
optimus wrote a nice explanation on how to do a radial blur, you can find it here: http://dbfinteractive.com/index.php?topic=219.0

//Johnny
Title: Re: Blurring
Post by: Jim on November 05, 2006
I wrote one over at the Yabasic forums, I think for Clyde, but I'm damned if I can find it.  I'd use the search there, but EzBoard is determined that I have never, in 5000+ posts, used the word 'rotation'.  I suspect they are wrong.

Jim
Title: Re: Blurring
Post by: Clyde on November 05, 2006
Hmmm, strange I can't remember asking about this or seeing any code ( thanks if you did ). Have looked through the entire Blitz Basic topic entries and tried searching also at the Yab / Homebrew forums, came up blankety blank.
Title: Re: Blurring
Post by: slinks on November 05, 2006
I wrote one over at the Yabasic forums, I think for Clyde, but I'm damned if I can find it.  I'd use the search there, but EzBoard is determined that I have never, in 5000+ posts, used the word 'rotation'.  I suspect they are wrong.

Jim


No, they might be right about that, I remember looking for a piece on rotation you wrote, can't remember what it was called, but it was a strange name. Most of the topics in that forum have bizarre names, and I had to search each topic MANUALLY for the bit I was looking for. Took ****ing ages!
Title: Re: Blurring
Post by: mind on January 05, 2007
i thought up a pretty clever and fast fake gaussian blur when i was writing my texture generator, i can post real source if you need it, but i'll try to explain it first..

normally when you blur you average the center pixel and a certain amount of it's neigbours.. say for example that you use top/left/center/right/bottom pixels..

now instead of just going
Code: [Select]
final=(source[x,y-1]+
       source[x-1,y]+
       source[x ,y ]+
       source[x+1,y]+
       source[x,y+1])/5;
destination[x,y]=final;
you use a variable to define the radius of the blur, and use that variable to decide where to grab your pixels, just like above only you use source[x,y-radius] instead of source[x,y-1];

now that alone doesnt cut it, what you need to do is to blur in several passes, decreasing radius for each pass.. so, lets say we do a 10pass gaussian blur, what we do now is something like this:
Code: [Select]
for radius =10 to 1 do
 for x=0 to 255 do
 for y=0 to 255 do
  begin
   final=(source[x,y-radius]+
          source[x-radius,y]+
          source[x ,y ]+
          source[x+radius,y]+
          source[x,y+radius])/5;
   destination[x,y]=final;
  end

i hope that helped you in some way.. if you wanna see the result the gaussian blur produce, try downloading my texture generator in this thread: http://dbfinteractive.com/index.php?topic=1070.0 (syntex.rar, somewhere in the thread) and play around with the blur.. to save you from wasting time implementing something that you didnt like :)