anton_foy
24th July 2024, 09:02
function dumden(clip o, int "t", int "tlum", int "tcol", float "spa", string "mode", float "omix")
{
### DUMDEN - a dumb and fast denoising function for calming down frenetic noise.
### High motion is more spatial than temporal, low motion is the opposite.
### Modes "one", "two" and "tre" to play around with.
### Need: Masktools2, neo-vaguedenoiser, rgtools, vsttempsmooth, gradationcurves(for mode "two").
t = Default(t, 3) # temporal radius
tlum = Default(tlum, 7) # temporal luma thresh
tcol = Default(tcol, 5) # temporal chroma thresh
spa = Default(spa, 2.0) # spatial strength
mode = Default(mode, "one") # modes: "one", "two, "tre"
omix = Default(omix, 0.25) # mix the original with the spatial filtering
cb = ExtractY(o).convertbits(8,dither=-1)
bit = BitsPerComponent(o)
ag = cb.coloryuv(autogain=true).merge(cb,0.56)
m1 = ag.mif(n=3).removegrain(20,-1).convertbits(bit)
at = ag.temporalsoften(1,255,0,255,2)
m2 = mt_makediff(at.merge(ag,0.42),at).ApplyGradationCurves(lumaPoints="0,0, 64,32, 128,128, 192,32, 255,0")
m2 = m2.mt_binarize(127).removegrain(20,-1).convertbits(bit)
m3 = ag.removegrain(20,-1).mt_motion(thy1=1,thy2=12).convertbits(bit)
sp = o.neo_vd(threshold=spa)
st = sp.merge(o,omix).vsttempsmooth(maxr=t,ythresh=tlum,uthresh=tcol,vthresh=tcol,ymdiff=2,umdiff=1,vmdiff=1)
out = \
mode == "one" ? mt_merge(st,st.merge(sp,0.75),m1,luma=true,u=3,v=3) : \
mode == "two" ? mt_merge(st.merge(sp,0.75),st,m2,luma=true,u=3,v=3) : \
mode == "tre" ? mt_merge(st,st.merge(sp,0.75),m3,luma=true,u=3,v=3) : \
return out
}
function Mif(clip C, int "n")
{
n=default(n, 2)
nr=string(n)
mt_lutxy(C, C.Trim(1, 0), mt_polish(" "+nr+" * abs(x-y)"), U=-128, V=-128)
return Last
}
You may replace 'vsttepsmooth' with 'temporalsoften(3,5,4,255,2)' if you like but I think then the motion "smearing" is a bit worse.
Any ideas are welcome :thanks:
{
### DUMDEN - a dumb and fast denoising function for calming down frenetic noise.
### High motion is more spatial than temporal, low motion is the opposite.
### Modes "one", "two" and "tre" to play around with.
### Need: Masktools2, neo-vaguedenoiser, rgtools, vsttempsmooth, gradationcurves(for mode "two").
t = Default(t, 3) # temporal radius
tlum = Default(tlum, 7) # temporal luma thresh
tcol = Default(tcol, 5) # temporal chroma thresh
spa = Default(spa, 2.0) # spatial strength
mode = Default(mode, "one") # modes: "one", "two, "tre"
omix = Default(omix, 0.25) # mix the original with the spatial filtering
cb = ExtractY(o).convertbits(8,dither=-1)
bit = BitsPerComponent(o)
ag = cb.coloryuv(autogain=true).merge(cb,0.56)
m1 = ag.mif(n=3).removegrain(20,-1).convertbits(bit)
at = ag.temporalsoften(1,255,0,255,2)
m2 = mt_makediff(at.merge(ag,0.42),at).ApplyGradationCurves(lumaPoints="0,0, 64,32, 128,128, 192,32, 255,0")
m2 = m2.mt_binarize(127).removegrain(20,-1).convertbits(bit)
m3 = ag.removegrain(20,-1).mt_motion(thy1=1,thy2=12).convertbits(bit)
sp = o.neo_vd(threshold=spa)
st = sp.merge(o,omix).vsttempsmooth(maxr=t,ythresh=tlum,uthresh=tcol,vthresh=tcol,ymdiff=2,umdiff=1,vmdiff=1)
out = \
mode == "one" ? mt_merge(st,st.merge(sp,0.75),m1,luma=true,u=3,v=3) : \
mode == "two" ? mt_merge(st.merge(sp,0.75),st,m2,luma=true,u=3,v=3) : \
mode == "tre" ? mt_merge(st,st.merge(sp,0.75),m3,luma=true,u=3,v=3) : \
return out
}
function Mif(clip C, int "n")
{
n=default(n, 2)
nr=string(n)
mt_lutxy(C, C.Trim(1, 0), mt_polish(" "+nr+" * abs(x-y)"), U=-128, V=-128)
return Last
}
You may replace 'vsttepsmooth' with 'temporalsoften(3,5,4,255,2)' if you like but I think then the motion "smearing" is a bit worse.
Any ideas are welcome :thanks: