View Single Post
Old 21st June 2010, 01:02   #19  |  Link
Jawed
Registered User
 
Join Date: Jan 2008
Location: London
Posts: 156
Just chain stuff together

e.g. I use this to kill blocking artefacts:

Code:
function BlockKiller(clip source)
{
    y=source.greyscale()
    y=y.ChannelBlockKiller() 
    u=source.utoy()
    u=u.ChannelBlockKiller() 
    v=source.vtoy()
    v=v.ChannelBlockKiller() 
      
    return ytouv(u, v, y)  
}

function ChannelBlockKiller(clip source)
{
    source
"""   spline36resize(source.width*16,source.height*16)
    gradfunkmirror() 
    gradfunkmirror() 
    gradfunkmirror() 
    spline36resize(source.width*8,source.height*8)
    gradfunkmirror() 
    gradfunkmirror() 
    gradfunkmirror() """
    spline36resize(source.width*4,source.height*4)
    gradfunkmirror() 
    gradfunkmirror() 
    gradfunkmirror() 
    spline36resize(source.width*2,source.height*2)
    gradfunkmirror() 
    gradfunkmirror() 
    gradfunkmirror() 
    spline36resize(source.width,source.height)
    gradfunkmirror() 
    gradfunkmirror() 
    gradfunkmirror() 

    return last
}
notice, in the function ChannelBlockKiller, that the *16 and *8 sections are commented out with the """. As posted, that code only uses *4 and *2 sizes, before returning the picture to its original size.

Basically you can adjust the maximum size, e.g. make it larger for smaller frames by un-commenting the *8 and *16 sections. The basic concept here is that any resizing algorithm creates a gradient on all edges (banding and non-banding). The gradient will be "smooth" but "regular". So then apply gradfunkmirror() to dither that gradient. Then resize down. Resizing down averages the dither.

The quantity of steps and the count of gradfunkmirror() calls per step adjust the result. You adjust for blockiness versus softness. (I'm still experimenting with this function - which is why there are no funky parameters, as I haven't decided which parameters are important and how to graduate the effect.)

In general you can simply use 2 or more instances of gradfunkmirror(), one after the other, to control most banding.

Also, I always use gradfunkmirror() on playback (the DeBand filter in FFDShow).

Jawed
Jawed is offline   Reply With Quote