Log in

View Full Version : Blur Function


Macanudo
17th January 2005, 12:19
I remember seeing a function in this forum that would allow one to apply a blur of 1.0 a variable number times. It eliminated the need to nest the blur function to achieve say a blur of 5.0.

I thought I saved the function, but apparently not, because I can't seem to locate it on my hard-drive. I have also done an exhaustive search of the forum with no luck.

I think it was written by Didee, but I could be wrong.

Can anyone direct me to this function please?

Thank You,
Macanudo

Didée
17th January 2005, 12:43
Originally posted by Macanudo
I think it was written by Didee, but I could be wrong.
I think you are. Can't recall to have made an iterated blur() function. The closest to that was LGauss() (http://forum.doom9.org/showthread.php?s=&postid=568119#post568119) (where last line's "U=1,V=1" must be set to "U=2,V=2" with new MaskTools versions), or that humoruous Multi-Resize-Thingy (http://forum.doom9.org/showthread.php?s=&postid=548860#post548860) for Aiataga ...

Chaining several blur() commands doesn't really yield to hi-Q blurring, as there will arise artefacts - especially banding - from accumulated rounding errors.
You're better off with Mug Funky's function for Gaussian blurring (this (http://forum.doom9.org/showthread.php?s=&threadid=85019&highlight=gauss) should be up to date) -- or build it yourself with either yv12convolution(), or by bicubic downsizing+upsizing (which is only an approximation, but generally should be good enough).

Macanudo
17th January 2005, 14:57
Originally posted by Didée
I think you are. Can't recall to have made an iterated blur() function. The closest to that was LGauss() (http://forum.doom9.org/showthread.php?s=&postid=568119#post568119) (where last line's "U=1,V=1" must be set to "U=2,V=2" with new MaskTools versions), or that humoruous Multi-Resize-Thingy (http://forum.doom9.org/showthread.php?s=&postid=548860#post548860) for Aiataga ...

Chaining several blur() commands doesn't really yield to hi-Q blurring, as there will arise artefacts - especially banding - from accumulated rounding errors.
You're better off with Mug Funky's function for Gaussian blurring (this (http://forum.doom9.org/showthread.php?s=&threadid=85019&highlight=gauss) should be up to date) -- or build it yourself with either yv12convolution(), or by bicubic downsizing+upsizing (which is only an approximation, but generally should be good enough).

Thank You for information and suggestions. I read on Avisynth.org that chaining the Blur filter was the way to achieve a Blur larger than 1.58. That is when I remembered the "multiple Blur function". I was unaware of the banding artifacts associated with it.

I am working on creating a "film look" from the "film look" thread and needed to apply a Gaussian Blur of 5.0 or above.

Thanks Again,
Macanudo

Mug Funky
17th January 2005, 14:59
ah, thanks didee - i was too lazy to dig that one up myself.

please note: the "useMMX=true" should be removed, as it'll break the script with newer masktools releases (and apparently it was always on by default... oops... placebo alert on my part).

it's not true gaussian blur - if you read through the code, you'll find that it's just 1 cycle of a sin^2 function stretched over the chosen blur radius. still looks nice though.

with default operation, it's not even that - it's a bilinear downsample and a (very blurry a=1,b=0) bicubic upsize. it actually gives very similar results to the convolution approach but is hella faster.

[edit]

that true, neuron? that should probably be added to the avs docs.

Guest
17th January 2005, 15:00
Iterating a fixed size box blur just approaches a fixed size gaussian blur. To increase the width of the gaussian you have to increase the width of the box. So if you are looking to get more blurring, iterating is not the answer. It just gives you a better gaussian shape.

Didée
17th January 2005, 15:30
Originally posted by Mug Funky
it's not true gaussian blur - if you read through the code, you'll find that it's just 1 cycle of a sin^2 function stretched over the chosen blur radius. still looks nice though.
Ah, indeed. Closer reading reveals you were cheating ;)

However, feeding yv12convolution() with the values of the odd lines of good old pascal's triangle is producing a true gaussian blur - e.g. for a radius-3 gaussian blur:

yv12convolution("1 6 15 20 15 6 1","1 6 15 20 15 6 1",Y=3,U=2,V=2) [luma only]


Macanudo: But for things like overlaying a blurred version, you are pretty fine off with a simple

bicubicresize(x/sqrt(radius),y/sqrt(radius).bicubicresize(x,y,1.0,.0)

Much faster, and you won't notice any difference ;)