Log in

View Full Version : Trying to port Ezdenoise,...


Selur
2nd June 2022, 17:02
I'm trying to port AviSynths EZdenoise (https://forum.doom9.org/showthread.php?p=1969853) (v3) which I thought would be rather straight forward.

AviSynth:

function EZdenoise(clip Input, int "thSAD", int "thSADC", int "TR", int "BLKSize", int "Overlap", int "Pel", bool "Chroma", float "Falloff")
{
thSAD = default(thSAD, 150)
thSADC = default(thSADC, thSAD)
TR = default(TR, 3)
BLKSize = default(BLKSize, 8)
Overlap = default(Overlap, 4)
Pel = default(Pel, 1)
Chroma = default(Chroma, false)
Falloff = default(Falloff, 0.9)

Super = Input.MSuper(Pel=Pel, Chroma=Chroma)
Multi_Vector = Super.MAnalyse(Multi=True, Delta=TR, BLKSize=BLKSize, Overlap=Overlap, Chroma=Chroma)

Input.MDegrainN(Super, Multi_Vector, TR, thSAD=thSAD, thSAD2=Int(thSAD*Falloff), thSADC=thSADC, thSADC2=Int(thSADC*Falloff))
}


My attempt in Vapoursynth:

# supports: GrayS, RGBS and YUV4xxPS
# requires libmvtools_sf_em64t (https://github.com/IFeelBloated/vapoursynth-mvtools-sf)
# mvmulti.py (https://github.com/Selur/VapoursynthScriptsInHybrid/blob/master/mvmulti.py)
def EZdenoise(clip: vs.VideoNode, thSAD: int=150, thSADC: int=-1, tr: int=3, blksize: int=8, overlap: int=4, pel: int=1, chroma: bool=False, falloff: float=0.9):
import mvmulti

if thSADC == -1:
thSADC = thSADC
Super = core.mvsf.Super(clip=clip, pel=pel, chroma=chroma)
Multi_Vector = mvmulti.Analyze(super=Super, tr=tr, blksize=blksize, overlap=overlap, chroma=chroma)

return mvmulti.DegrainN(clip=clip, super=Super, mvmulti=Multi_Vector, tr=tr, thsad=thSAD, thscd1=thSADC, thscd2=int(thSADC*falloff))

Problem is using:

clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
org = clip
clip = EZdenoise(clip=clip, thSAD=16000)
diff = core.std.MakeDiff(org, clip)
clip = core.text.Text(clip=clip, text="filtered")
org = core.text.Text(clip=org, text="org")
clip = core.std.Interleave([org, clip, diff])

I get no errors, but I see no difference between the filtered and the original clip. :/
First I thought it might be the file I used, but using different files I still do not see a difference, so I suspect that I overlooked something.

=> Does anyone spot my mistake?

:confused:

Cu Selur

lansing
2nd June 2022, 18:11
It's just smdegrain

Selur
2nd June 2022, 19:54
@lansing: doesn't explain why the Vapoursynth version isn't working,...

Cu Selur

Ps.: my motivation is not to find a 'super' denoiser/degrainer, but to learn a bit how to port Avisynth scripts to Vapoursynth

Julek
2nd June 2022, 21:14
thSADC = thSADC?

Selur
3rd June 2022, 07:05
@Julek: THANKS! Totally overlooked it, should be 'thSADC = thSAD". :)
So fixed version is:
# supports: GrayS, RGBS and YUV4xxPS
# requires libmvtools_sf_em64t (https://github.com/IFeelBloated/vapoursynth-mvtools-sf)
# mvmulti.py (https://github.com/Selur/VapoursynthScriptsInHybrid/blob/master/mvmulti.py)
def EZdenoise(clip: vs.VideoNode, thSAD: int=150, thSADC: int=-1, tr: int=3, blksize: int=8, overlap: int=4, pel: int=1, chroma: bool=False, falloff: float=0.9):
import mvmulti

if thSADC == -1:
thSADC = thSAD
Super = core.mvsf.Super(clip=clip, pel=pel, chroma=chroma)
Multi_Vector = mvmulti.Analyze(super=Super, tr=tr, blksize=blksize, overlap=overlap, chroma=chroma)

return mvmulti.DegrainN(clip=clip, super=Super, mvmulti=Multi_Vector, tr=tr, thsad=thSAD, thscd1=thSADC, thscd2=int(thSADC*falloff))

Cu Selur