logo Sign In

Post #724401

Author
althor1138
Parent topic
Film cleanup (in avisynth I guess)
Link to post in topic
https://originaltrilogy.com/post/id/724401/action/topic#724401
Date created
26-Aug-2014, 2:28 PM

In my opinion, a motion compensated dfttest is the best denoiser at the moment. It requires dfttest and mvtools2 if I recall correctly. Paste this into the bottom of any script and it should work as long as you have the dfttest and mvtools2 installed and autoloaded in the plugin directory.

function dfttestMC(clip input, clip "pp", int "mc", bool "mdg", bool "Y", bool "U", bool "V", float "sigma", int "sbsize", int "sosize", int "tbsize", int "dither",

\ string "dfttest_params", int "mdgSAD", int "thSAD", int "thSCD1", int "thSCD2", int "pel", int "blksize", int "search", int "searchparam", int "overlap", int "dct", bool "lsb")

{

# Set default options. Most external parameters are passed valueless.

mc = default(mc, 2).min(5)

mdg = default(mdg, false)

Y = default(Y, true)

U = default(U, true)

V = default(V, true)

tbsize = default(tbsize, mc * 2 + 1)

dfttest_params = default(dfttest_params, "")

overlap = default(overlap, 2)

lsb= default(lsb,false)

# Set chroma parameters.

chroma = U || V

plane = U && !Y && !V ? 1 : V && !Y && !U ? 2 : chroma && !Y ? 3 : Y && chroma ? 4 : 0

# Prepare supersampled clips.

pp_enabled = defined(pp)

pp_super = pp_enabled ? MSuper(pp, pel=pel, chroma=chroma) : MSuper(input, pel=pel, chroma=chroma)

super = pp_enabled ? input.MSuper(pel=pel, levels=1, chroma=chroma) : pp_super

# Motion vector search.

b5vec = MAnalyse(pp_super, delta=5, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, dct=dct)

b4vec = MAnalyse(pp_super, delta=4, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

b3vec = MAnalyse(pp_super, delta=3, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

b2vec = MAnalyse(pp_super, delta=2, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

b1vec = MAnalyse(pp_super, delta=1, isb=true, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

f1vec = MAnalyse(pp_super, delta=1, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

f2vec = MAnalyse(pp_super, delta=2, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

f3vec = MAnalyse(pp_super, delta=3, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

f4vec = MAnalyse(pp_super, delta=4, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

f5vec = MAnalyse(pp_super, delta=5, chroma=chroma, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

# Motion Compensation.

b5clip = MCompensate(input, super, b5vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

b4clip = MCompensate(input, super, b4vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

b3clip = MCompensate(input, super, b3vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

b2clip = MCompensate(input, super, b2vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

b1clip = MCompensate(input, super, b1vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

f1clip = MCompensate(input, super, f1vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

f2clip = MCompensate(input, super, f2vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

f3clip = MCompensate(input, super, f3vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

f4clip = MCompensate(input, super, f4vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

f5clip = MCompensate(input, super, f5vec, thSAD=thSAD, thSCD1=thSCD1, thSCD2=thSCD2)

# Create compensated clip.

interleaved = mc >= 5 ? Interleave(f5clip, f4clip, f3clip, f2clip, f1clip, input, b1clip, b2clip, b3clip, b4clip, b5clip) :

\ mc == 4 ? Interleave(f4clip, f3clip, f2clip, f1clip, input, b1clip, b2clip, b3clip, b4clip) :

\ mc == 3 ? Interleave(f3clip, f2clip, f1clip, input, b1clip, b2clip, b3clip) :

\ mc == 2 ? Interleave(f2clip, f1clip, input, b1clip, b2clip) :

\ mc == 1 ? Interleave(f1clip, input, b1clip):

\ mc == 0 ? input:

\ input

# Perform dfttest.

filtered = Eval("dfttest(interleaved, Y=Y, U=U, V=V, sigma=sigma, sbsize=sbsize, sosize=sosize,tbsize=tbsize,dither=dither)")

return SelectEvery(filtered, mc * 2 + 1, mc)

}

I only ever use the sigma and mc (motion compensation) parameters. I don't go too high with the mc parameter because it sometimes introduces some artifacts with high motion scenes.

Something like this:

myfilmclip.dfttestmc(sigma=8,mc=1)

Fred's 8mm script is probably the best way to do automated dirt cleanup. You can disable almost any portion of the script and use only what you want.  He's got it all laid out in the appropriate order so you don't do any processing out of order. What method did Laserschwert use?  That seemed to work really well.