Hello guest, if you like this forum, why don't you register? https://fanrestore.com/member.php?action=register (December 14, 2021) x


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AviSynth LD Denoiser
#1
This is a denoiser made by althor1138 and posted on OT a long time ago; I think it could be useful for someone here, too.

Code:
function LDdenoise(clip input, float "strength", int "mc", int "temporalframes",\
int "blksize", int "search", int "searchparam", int "overlap", int "dct")
{

# Set default options.

strength=default(strength,1)
   temporalframes=default(temporalframes,1)
mc = default(mc, 0)

# Prepare supersampled clip.

super = input.MSuper(levels=6,chroma=true)

# Motion vector search.

b5vec = MAnalyse(super, delta=5, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, dct=dct)
b4vec = MAnalyse(super, delta=4, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
b3vec = MAnalyse(super, delta=3, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
b2vec = MAnalyse(super, delta=2, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
b1vec = MAnalyse(super, delta=1, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f1vec = MAnalyse(super, delta=1, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f2vec = MAnalyse(super, delta=2, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f3vec = MAnalyse(super, delta=3, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f4vec = MAnalyse(super, delta=4, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f5vec = MAnalyse(super, delta=5, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

# Motion Compensation.

b5clip = MCompensate(input,super, b5vec)
b4clip = MCompensate(input,super, b4vec)
b3clip = MCompensate(input,super, b3vec)
b2clip = MCompensate(input,super, b2vec)
b1clip = MCompensate(input,super, b1vec)
f1clip = MCompensate(input,super, f1vec)
f2clip = MCompensate(input,super, f2vec)
f3clip = MCompensate(input,super, f3vec)
f4clip = MCompensate(input,super, f4vec)
f5clip = MCompensate(input,super, f5vec)

# 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):
\ input

#Perform DFTTEST

params="""dfttest(y=true,u=true,v=true,f0beta=0.5,sigma=0,dither=0,sbsize=25,sosize=20,tbsize="""+string(temporalframes)+""",tosize="""+string(temporalframes)+"""/3,nstring=\
   "a:"""+string(strength)+""" \
   "+string(current_frame)+",0,440,10 \
   "+string(current_frame)+",0,10,10 \
   "+string(current_frame)+",0,10,340 \
   "+string(current_frame)+",0,10,680 \
   "+string(current_frame)+",0,440,680 \
   "+string(current_frame)+",1,440/2,3 \
   "+string(current_frame)+",1,3,3 \
   "+string(current_frame)+",1,3,340/2 \
   "+string(current_frame)+",1,3,680/2 \
   "+string(current_frame)+",1,440/2,350 \
   "+string(current_frame)+",2,120,3 \
   "+string(current_frame)+",2,3,3 \
   "+string(current_frame)+",2,3,340/2 \
   "+string(current_frame)+",2,3,680/2 \
   "+string(current_frame)+",2,440/2,680/2")
   """
filter=eval("scriptclip(interleaved,params)")
return SelectEvery(filter, mc * 2 + 1,mc)

}

function LDdenoise2(clip input, float "strength", int "mc", int "temporalframes",\
int "blksize", int "search", int "searchparam", int "overlap", int "dct")
{

# Set default options.

width=width(input)
height=height(input)
strength=default(strength,1)
temporalframes=default(temporalframes,1)
mc = default(mc, 0)

# Prepare supersampled clip.

super = input.MSuper(levels=6,chroma=true)

# Motion vector search.

b5vec = MAnalyse(super, delta=5, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, dct=dct)
b4vec = MAnalyse(super, delta=4, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
b3vec = MAnalyse(super, delta=3, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
b2vec = MAnalyse(super, delta=2, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
b1vec = MAnalyse(super, delta=1, isb=true,chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f1vec = MAnalyse(super, delta=1, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f2vec = MAnalyse(super, delta=2, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f3vec = MAnalyse(super, delta=3, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f4vec = MAnalyse(super, delta=4, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)
f5vec = MAnalyse(super, delta=5, chroma=true, search=search, searchparam=searchparam, overlap=overlap, blksize=blksize, dct=dct)

# Motion Compensation.

b5clip = MCompensate(input,super, b5vec)
b4clip = MCompensate(input,super, b4vec)
b3clip = MCompensate(input,super, b3vec)
b2clip = MCompensate(input,super, b2vec)
b1clip = MCompensate(input,super, b1vec)
f1clip = MCompensate(input,super, f1vec)
f2clip = MCompensate(input,super, f2vec)
f3clip = MCompensate(input,super, f3vec)
f4clip = MCompensate(input,super, f4vec)
f5clip = MCompensate(input,super, f5vec)

# 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):
\ input

#Perform DFTTEST

yparams="""dfttest(y=true,u=false,v=false,f0beta=0.5,sigma=0,dither=0,sbsize=25,sosize=20,tbsize="""+string(temporalframes)+""",tosize="""+string(temporalframes)+"""/3,nstring=\
"a:"""+string(strength)+""" \
"+string(current_frame)+",0,"""+string(height-40)+""",10 \
"+string(current_frame)+",0,10,10 \
"+string(current_frame)+",0,10,"""+string(width/4)+""" \
"+string(current_frame)+",0,10,"""+string(width/2)+""" \
"+string(current_frame)+",0,10,"""+string(width/1.5)+""" \
"+string(current_frame)+",0,10,"""+string(width-40)+""" \
"+string(current_frame)+",0,"""+string(height-40)+""","""+string(width-40)+""" ")
"""


yfilter=eval("scriptclip(interleaved,yparams)")

uvparams="""dfttest(y=false,u=true,v=true,f0beta=0.5,sigma=0,dither=0,sbsize=25,sosize=20,tbsize="""+string(temporalframes)+""",tosize="""+string(temporalframes)+"""/3,nstring=\
"a:"""+string(strength)+""" \
"+string(current_frame)+",1,"""+string((height/2)-30)+""",3 \
"+string(current_frame)+",1,3,3 \
"+string(current_frame)+",1,3,"""+string((width/2)/2)+""" \
"+string(current_frame)+",1,3,"""+string((width/2)-30)+""" \
"+string(current_frame)+",1,"""+string((height/2)-30)+""","""+string((width/2)-30)+""" \
"+string(current_frame)+",2,"""+string((height/2)-30)+""",3 \
"+string(current_frame)+",2,3,3 \
"+string(current_frame)+",2,3,"""+string((width/2)/2)+""" \
"+string(current_frame)+",2,3,"""+string((width/2)-30)+""" \
"+string(current_frame)+",2,"""+string((height/2)-30)+""","""+string((width/2)-30)+""" ")
"""

uvfilter=eval("scriptclip(yfilter,uvparams)")

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

}
Reply
Thanks given by: pipefan413


Possibly Related Threads…
Thread Author Replies Views Last Post
  AviSynth TSMC (Temporal Soften Motion Compensated)(Denoiser) althor1138 28 27,614 2018-08-06, 12:38 PM
Last Post: althor1138

Forum Jump:


Users browsing this thread: 1 Guest(s)