View Single Post
Old 31st March 2005, 18:41   #12  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Indeed. Chaining several blur()'s theoretically is the right thing. But in practice, there will be an accumulation of rounding errors, which lead to a) inefficiency for big radii and b) sometimes nasty artefacts, especially in flat areas.

For doing a pretty precise gaussian blur, yv12convolution is just it. However for most tasks, the resizing combo is precise enough, and it's really so much faster. It's probably not so awfully important for a single operation, but if you need several of them ... I'm fiddling with a script that internally uses a good bunch of different gaussian-blur operations. Doing all of them through BicubicResize, speed is slow, but acceptable. Exchanging all of'em with yv12convolution, Vdub's processing window is too small to completely hold the numbers for "estimated time" ...

This one is fast, precise enough, and also allows different radii for x-axis and y-axis:

Code:
function FastGaussBlur(clip clp, float rx, float "ry")
{
ry = default(ry, rx)
rx = rx+1.0
ry = ry+1.0
ox = clp.width
oy = clp.height
oxs1 = int(round(ox/4.0/sqrt(rx))*4)
oys1 = int(round(oy/4.0/sqrt(ry))*4)
oxs2 = int(round(sqrt(ox*oxs1)/4.0)*4)
oys2 = int(round(sqrt(oy*oys1)/4.0)*4)
oxs1 = oxs1<16 ? 16 : oxs1
oys1 = oys1<16 ? 16 : oys1
clp.bicubicresize(oxs1,oys1)
rx>9.0||ry>9.0 ? bicubicresize(oxs2,oys2,0.5,0.25) : last
return bicubicresize(ox,oy,1,0) 
}
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote