Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 24th July 2024, 09:02   #1  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 715
Dumden - denoise

Code:
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

Last edited by anton_foy; 24th July 2024 at 11:31. Reason: Tweaked params and cleaned up
anton_foy is offline   Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.