Log in

View Full Version : TemporalDegrainV2


Pages : 1 2 3 4 5 [6] 7

kedautinh12
30th April 2022, 19:57
I seen different between 2.4.3 and 2.5.1 in list download about changelogs and DT_BM3D function

ErazorTT
1st May 2022, 12:36
I removed again the paramter divSADc to make things easier for the user. Improved cleanup of the chroma planes generally. No performance impact (<1% speed difference).
The right selection of grainLevel has now however somewhat gained in importance.

With the same parameters as in the second picture of my previous post this leads to the following result (grainLevel=2,degrainTR=2,postFFT=1,postSigma=2):
https://i.postimg.cc/H8XHH5j8/2-6-0-gl2tr2ps2.jpg (https://postimg.cc/H8XHH5j8)
This result is right inbetween the last two pictures of my previous post!

kedautinh12
8th May 2022, 16:48
After got latest ver i got errors when use with postFFT=4 i got what 'devID' means, with postFFT=5 i got what 'devID' means and what 'cuda' means

ErazorTT
10th May 2022, 16:08
Yeah, right. I fixed it now in v2.6.2.

StvG
4th June 2022, 05:44
v2.6.2 - line #483:
ch ? output.MatchClip(a) : output.mergechroma(a)

What is the filter MatchClip?

kedautinh12
4th June 2022, 06:02
v2.6.2 - line #483:
ch ? output.MatchClip(a) : output.mergechroma(a)

What is the filter MatchClip?

It's is script from Dogway
https://github.com/Dogway/Avisynth-Scripts/blob/c113ff30e37f47d8117c1b3db8f00599cc62e267/TransformsPack%20-%20Main.avsi#L110

And other scripts from Dogway to work MatchClip functions

StvG
4th June 2022, 06:07
Thanks. I did see the optional plugins.

ErazorTT
9th June 2022, 11:45
main change is that by default its now possible to use multiple instances. For example for using different settings on different parts of the clip. Depending on the settings, this will need a lot of memory!

mastrboy
12th June 2022, 20:25
Is there a github or similar page for this? This forum is very slow at approving attachements: Attachments Pending Approval: File Type: zip TemporalDegrain-v2.6.3.zip

Zetti
12th June 2022, 22:14
You can grab it from his Google Drive in post 1

PatchWorKs
16th June 2022, 17:39
@ErazorTT Out of curiosity: do you think is possible to speedup your great software by using QuickSync instructions ?

Selur
17th June 2022, 13:33
in Temporal Degrain v2.6.3 line 202:
outputStage= default( outputStage, 2 ) # [0, 2] you can decide to skip the processing of later stages and directly output the clip as process of the stage given: 0= output after first degraining, 1= output after second degraining, 2= output after FFT post processing, 3= output after contra sharpening (that's the last stage and the default)
-> text says 3 is default, but code says range is 0-2 and default is 2.

cork_OS
24th June 2022, 21:46
UPD: wrong info

Selur
24th June 2022, 22:20
works fine here with google drive,.. (might be blocked due to you location)

StainlessS
26th June 2022, 11:25
I quite often have small probs downloading from Google Drive, but usually starts eventually if you give it a minute or so,
works better if you're signed in to your Google account. (I usually stay signed out unless required)

Maybe some kind of punishment for not being signed in,
Hotmail, on signing in using non MS Edge browser, just hangs for about 30 seconds (or is it 60), punishment for not using Edge [EDIT: Zero network activity until punishment ends].
(I usually start it up before I want to use it, and switch back to what I was doing for a couple of minutes so that it will have dished out sufficient punishment.)

EDIT: Above Hotmail Edge punishement thing, is where (my) MS telemetry is disabled/crippled, perhaps Edge also passes telemetry and where not using edge, then
attempts standard MS telemetry spyware stuff until it figures out that it is also blocked.

anton_foy
17th July 2022, 12:07
Trying to understand the TemporalDegrain2-script as it works really well with my footage but I would like to add an option to dynamically adjust postSigma with my noise detection and ScriptClip. Is it possible to mod it using ScriptClip only for postFFT? Have tried a while to get it to work but it seems to ignore the FFT3dFilter I use for ScriptClip. Putting the whole TemporalDegrain2 inside of ScriptClip is impossibly slow.


function FD(clip c)
{
# Noise extraction - normalizing the image to even out motion leaving "only" moving noise.

in = c.levels(6*256,1,122*256,0,255*256).tdif.ApplyGradationCurves(lumaPoints="0,128, 40,0, 128,255, 213,0, 255,128")
nc = SI_physicalcores()
ScriptClip(function[in,nc] () {

# Noise detection
nTH = in.YDifferenceToNext()
s = nmod(nTH*0.00009, dec=1)
fft3dfilter(sigma=s, bt=3, ncpu=nc, plane=4)
} )
}
# TemporalDifference - noise enhancing
function tdif(clip C)
{
mt_lutxy(C, C.Trim(1, 0), mt_polish("16*abs(x-y)"), U=-128, V=-128)
return Last
}

function DT_postFFT(clip in, int postFFT, int postPlane, float postSigma, int postDither, int postTR, int postTD, int fftThreads, int postBlkSz, int devId, bool cuda, string dftsfile)
{
LumaNoiseP = (postPlane == 0) || (postPlane == 4)
ChromaNoiseP = (postPlane > 0) ? true : false
dftDither = (postDither < 0) ? postDither*(-1) : 0

out = (postFFT == 0) ? FD( postDither > 0 ? in.ConvertBits(16) : in) : \
(postFFT == 1) ? neo_fft3d ( postDither > 0 ? in.ConvertBits(16) : in, y=LumaNoiseP?3:2, u=ChromaNoiseP?3:2, v=ChromaNoiseP?3:2, sigma=postSigma, bt=postTD, ncpu=fftThreads, bw=postBlkSz, bh=postBlkSz ) : \
(postFFT == 11)? FFT3DFilter( postDither > 0 ? in.ConvertBits(16) : in, plane=postPlane, sigma=postSigma, bt=postTD, ncpu=fftThreads, bw=postBlkSz, bh=postBlkSz ) : \
(postFFT == 2) ? FFT3DGPU( postDither > 0 ? in.ConvertBits(16) : in, plane=postPlane, sigma=postSigma*2/3, bt=postTD, precision=2, mode=1, bw=postBlkSz, bh=postBlkSz ) : \
(postFFT == 3) ? neo_dfttest( postDither > 0 ? in.ConvertBits(16) : in, y=LumaNoiseP?3:2, u=ChromaNoiseP?3:2, v=ChromaNoiseP?3:2, sigma=postSigma*4, tbsize=postTD, dither=dftDither, threads=fftThreads, sbsize=postBlkSz, sosize=postBlkSz*9/12, slocation=dftsfile) : \
(postFFT == 13)? dfttest( postDither > 0 ? in.ConvertBits(16) : in, Y=LumaNoiseP, U=ChromaNoiseP, V=ChromaNoiseP, sigma=postSigma*4, tbsize=postTD, threads=fftThreads, dither=dftDither, sbsize=postBlkSz, sosize=postBlkSz*9/12, sfile=dftsfile ) : \
(postFFT == 4) ? DT_KNLMeansCL( postDither > 0 ? in.ConvertBits(16) : in, a=2, d=postTR, h=postSigma, Luma = LumaNoiseP, Chroma = ChromaNoiseP, device_type="GPU", device_id=devId) : \
(postFFT == 5) ? DT_BM3D( postDither > 0 ? in.ConvertBits(16) : in, radius=postTR, sigma=postSigma, chroma=ChromaNoiseP, CUDA=cuda, device_id=devId ) : \
(postFFT == -1)? HQDn3D( postDither > 0 ? in.ConvertBits(16) : in, 0,0,4,1, u=ChromaNoiseP?3:2, v=ChromaNoiseP?3:2) : NOP()

return out
}


Replaced postFFT=0 just to test. I guess FFT3DFilter needs to work together with the degraining bit for it to work as intended?

EDIT: the above is just the code-snippet of the parts I changed in TemporalDegrain-v2.6.3.avsi

kedautinh12
17th July 2022, 12:24
Trying to understand the TemporalDegrain2-script as it works really well with my footage but I would like to add an option to dynamically adjust postSigma with my noise detection and ScriptClip. Is it possible to mod it using ScriptClip only for postFFT? Have tried a while to get it to work but it seems to ignore the FFT3dFilter I use for ScriptClip. Putting the whole TemporalDegrain2 inside of ScriptClip is impossibly slow.


function FD(clip c)
{
# Noise extraction - normalizing the image to even out motion leaving "only" moving noise.

in = c.levels(6*256,1,122*256,0,255*256).tdif.ApplyGradationCurves(lumaPoints="0,128, 40,0, 128,255, 213,0, 255,128")
nc = SI_physicalcores()
ScriptClip(function[in,nc] () {

# Noise detection
nTH = in.YDifferenceToNext()
s = nmod(nTH*0.00009, dec=1)
fft3dfilter(sigma=s, bt=3, ncpu=nc, plane=4)
} )
}
# TemporalDifference - noise enhancing
function tdif(clip C)
{
mt_lutxy(C, C.Trim(1, 0), mt_polish("16*abs(x-y)"), U=-128, V=-128)
return Last
}

function DT_postFFT(clip in, int postFFT, int postPlane, float postSigma, int postDither, int postTR, int postTD, int fftThreads, int postBlkSz, int devId, bool cuda, string dftsfile)
{
LumaNoiseP = (postPlane == 0) || (postPlane == 4)
ChromaNoiseP = (postPlane > 0) ? true : false
dftDither = (postDither < 0) ? postDither*(-1) : 0

out = (postFFT == 0) ? FD( postDither > 0 ? in.ConvertBits(16) : in) : \
(postFFT == 1) ? neo_fft3d ( postDither > 0 ? in.ConvertBits(16) : in, y=LumaNoiseP?3:2, u=ChromaNoiseP?3:2, v=ChromaNoiseP?3:2, sigma=postSigma, bt=postTD, ncpu=fftThreads, bw=postBlkSz, bh=postBlkSz ) : \
(postFFT == 11)? FFT3DFilter( postDither > 0 ? in.ConvertBits(16) : in, plane=postPlane, sigma=postSigma, bt=postTD, ncpu=fftThreads, bw=postBlkSz, bh=postBlkSz ) : \
(postFFT == 2) ? FFT3DGPU( postDither > 0 ? in.ConvertBits(16) : in, plane=postPlane, sigma=postSigma*2/3, bt=postTD, precision=2, mode=1, bw=postBlkSz, bh=postBlkSz ) : \
(postFFT == 3) ? neo_dfttest( postDither > 0 ? in.ConvertBits(16) : in, y=LumaNoiseP?3:2, u=ChromaNoiseP?3:2, v=ChromaNoiseP?3:2, sigma=postSigma*4, tbsize=postTD, dither=dftDither, threads=fftThreads, sbsize=postBlkSz, sosize=postBlkSz*9/12, slocation=dftsfile) : \
(postFFT == 13)? dfttest( postDither > 0 ? in.ConvertBits(16) : in, Y=LumaNoiseP, U=ChromaNoiseP, V=ChromaNoiseP, sigma=postSigma*4, tbsize=postTD, threads=fftThreads, dither=dftDither, sbsize=postBlkSz, sosize=postBlkSz*9/12, sfile=dftsfile ) : \
(postFFT == 4) ? DT_KNLMeansCL( postDither > 0 ? in.ConvertBits(16) : in, a=2, d=postTR, h=postSigma, Luma = LumaNoiseP, Chroma = ChromaNoiseP, device_type="GPU", device_id=devId) : \
(postFFT == 5) ? DT_BM3D( postDither > 0 ? in.ConvertBits(16) : in, radius=postTR, sigma=postSigma, chroma=ChromaNoiseP, CUDA=cuda, device_id=devId ) : \
(postFFT == -1)? HQDn3D( postDither > 0 ? in.ConvertBits(16) : in, 0,0,4,1, u=ChromaNoiseP?3:2, v=ChromaNoiseP?3:2) : NOP()

return out
}


Replaced postFFT=0 just to test. I guess FFT3DFilter needs to work together with the degraining bit for it to work as intended?

I remember you run very slow with neo-fft3t. Try limitFFT=11, TemporalDegrain2 will use fft3d filter

anton_foy
17th July 2022, 13:14
I remember you run very slow with neo-fft3t. Try limitFFT=11, TemporalDegrain2 will use fft3d filter

Thanks, now I have upgraded my computer a bit and neo-fft works fine.
Although I talking about modding the TemporalDegrain-script to make neo/fft3dfilter work in scriptclip in the way I suggested above.

EDIT: Now I think I found out a bit more about what is doing what. As I understand it there are two instances where FFT3D is used.
First as a kind of prefilter(?) in DGlimit and second instance as postFFT. Will try to experiment with DGlimit-FFT3D + ScriptClip.

simple_simon
22nd September 2022, 16:34
What would be the best settings in TemporalDegrainV2 to best replicate the FastDegrain.avsi from the original TemporalDegrain package but utilizing the added QTGMC analysis benefits?

ErazorTT
30th September 2022, 21:36
I at least have no idea. I never tried to replicate any other plugin. Just read the step-by-step readme at the top of the TD2.avsi script and it will guide you through the setup of TD2 for the clip at hand.

some dude
21st October 2022, 14:42
I'm running into a weird issue, I don't think I'm missing any of the dependent plugins.

Avisynth open failure:
unexpected character "["
(TemporalDegrain-v2.6.2.avsi, line 478, column 41)


The line it appears to be referring to is

output = cd ? output.BM3D_CUDA(sigma=[s,cs,cs], radius=r, chroma=chr, fast=true, extractor_exp=6, device_id=devId)

I'm not sure why it can't read the "[" character.

StainlessS
21st October 2022, 14:56
I'm not sure why it can't read the "[" character.
You running latest avs+ ?

(Looks like some kind of Array stuff)

EDIT:
output = cd ? output.BM3D_CUDA(sigma=[s,cs,cs], radius=r, chroma=chr, fast=true, extractor_exp=6, device_id=devId)
Does that require the Cuda version AVS+ ???

Reel.Deel
21st October 2022, 16:18
Does that require the Cuda version AVS+ ???

No it does not require the CUDA version. The only filters known that require AviSynth+ built with the CUDA option are Nekopanda's CUDA filters (https://github.com/pinterf/AviSynthCUDAFilters#readme). But there is no current compile of those filters that work with the latest AVS+: https://github.com/AviSynth/AviSynthPlus/issues/296

subterrestrial
3rd December 2022, 02:34
I came across this topic when I was searching for reference to help me mod a denoising script using Nekopanda's CUDA functions as I really like the efficiency of these cuda filters. TemporalDegrain2 seems to be a nice start point since it is partly based on QTGMC degrain algorithm of which the cuda version realization already exists.

It might be off this topic but I want to share some information about compiling the printerf version AviSynthCUDAFilters because I read the reply referred that there was problems in compling these filters with AVS+3.7.2.
When I compiled printerf's AviSynthCUDAFilters with AVS+3.7.0 by CUDA11 compiler and run the program using a pascal architecture card(GTX10xx series, just like the one which printerf got when he moded the soure file), it worked very well. But when I changed the card to a turing architecture card(GTX16xx and RTX20xx) and comiled the file again with AVS+3.7.2, the filter failed to work. It seemed the graphic gard memory and cpu memory failed to synchronise. The same problem was also reported in a Japanese forum where there is special column discussing Avisynth topics(https://toro.2ch.sc/test/read.cgi/avi/1653113801/l50).

Anyway, I finally figured out a way to make it work: using CUDA 8 compiler to compile printerf's AviSynthCUDAFilters, in this way I could make the program run on a turing architecture card but I can't guarantee it can run ampere architecture card(RTX30xx) because I don't have a card for testing. However, it seems that the program may run on ampere architecture cards sinse Nekopanda's programs was compiled by CUDA8 compiler and the programs were reported to work on those cards(https://mevius.5ch.net/test/read.cgi/avi/1666875696/).

Sorry but there are more off topic things I want to add. Actually the source code that Nekopanda compiled his last version cuda filters which is in his repository of Amtsukaze project was not updated to his repository of AviSynthCUDAFilters project. The date in which the program file was comiled was about half year later than the date of the final change in his AviSynthCUDAFilters project. Another decisive evidence is that a funtion in printerf's AviSynthCUDAFilters is lacking a parameter which resulted in KFMDeint.avsi in Amtsukaze failing directly applied in(bool "is120" in function KFMDeint). Additionally, although I know it's not a sufficient evidence, I compiled Nekopanda version using the not updated code by CUDA 8 compiler and compare the efficiency with Nekopanda's compiled files running same program but just replacing the dll file in the Amtsukaze folder, then I founed mine was not efficient as Nekopanda's . Since Nekopanda's AvsCUDA.dll and KFM.dll was both comiled half year later than the last updated code, I'm pretty sure there are code changes in the soure file. After all, in my guess Nekopanda's main and final purpose was not to create these filters, which were just tools he created to build his final program Amtsukaze of which I just find out the maintainance has been taken over by rigaya(https://github.com/rigaya/Amatsukaze) though he/she didn't touch the AviSynthCUDAFilters codes.

kedautinh12
3rd December 2022, 02:50
I'm running into a weird issue, I don't think I'm missing any of the dependent plugins.

Avisynth open failure:
unexpected character "["
(TemporalDegrain-v2.6.2.avsi, line 478, column 41)


The line it appears to be referring to is

output = cd ? output.BM3D_CUDA(sigma=[s,cs,cs], radius=r, chroma=chr, fast=true, extractor_exp=6, device_id=devId)

I'm not sure why it can't read the "[" character.

You need use latest avs+ ver
https://gitlab.com/uvz/AviSynthPlus-Builds

You need use update TemporalDegrain2 to latest ver (check first post)

You don't need Cuda if you use this script:
TemporalDegrain2 (postFFT=5, cuda=false)

Arx1meD
8th February 2023, 12:53
I like everything in Temporaldegrainv2 and the quality of the cleaning of the noise is brilliant! But the speed of work is slow, and on my old computer it works very slowly. I decided to change the script so that it works faster and cleaned well from noise.
This is my lightweight version - Temporaldegrain2_fast.
# Temporal Degrain 2 fast
#
# Based on TemporalDegrainV2
# https://forum.doom9.org/showthread.php?t=175798
#
# Needed plugins:
# neo_FFT3D https://github.com/HomeOfAviSynthPlusEvolution/neo_FFT3D
# MaskTools2 https://github.com/pinterf/masktools
# MVTools2 https://github.com/pinterf/mvtools or https://github.com/DTL2020/mvtools
# RgTools https://github.com/pinterf/RgTools
# vsDeGrainMedian https://github.com/Asd-g/AviSynth-vsDeGrainMedian
#
# Usage Default:
# TemporalDegrain2_fast(Strength=3, Y=3, U=3, V=3, RadT=1, BlkSz=16, Sharp=0.4, PostDeHalo=false, PostMix=0)
#
# Post in Doom9's forum: https://forum.doom9.org/showthread.php?p=1982594#post1982594


function TemporalDegrain2_fast (clip input, int "Strength", int "Y", int "U", int "V", int "RadT", int "BlkSz", int "Olap", \
float "Sharp", bool "PostDeHalo", float "PostMix")
{
Str = Default(Strength, 3) # Noise/grain suppression strength.
# Strength for depth noise (< 2), low (3 ... 5), medium (6 ... 9), high (10 ... 14), veryhigh (> 15)
Y = Default(Y, 3) # Luma plane to process. Value: 2 - copy from input, 3 - process
U = Default(U, Y) # Chroma plane to process. Value: 2 - copy from input, 3 - process
V = Default(V, U) # Chroma plane to process. Value: 2 - copy from input, 3 - process
RadT = Default(RadT, 1) # Temporal Radius of frame analysis. Value 1 or 2
BlkSz = Default(BlkSz, 16) # Block size for motion analysis. Bigger BlkSz quicker. Recommended values: 8, 16, 32
OLap = Default(OLap, BlkSz/2) # The value of overlapping blocks on each other
Sharp = Default(Sharp, 0.4) # Sharpening strength. Range: 0 ... 1
DeHalo = Default(PostDeHalo, false) # Remove halo after sharpening. Value: true or false
PostMix = Default(PostMix, 0) # How much noise/grain will be returned. Range: 0 ... 1

func_name = "TemporalDegrain2_fast: "
Assert(Y == 2 || Y == 3, func_name+"Luma Y plane must be 2 or 3")
Assert(U == 2 || U == 3, func_name+"Chroma U plane must be 2 or 3")
Assert(V == 2 || V == 3, func_name+"Chroma V plane must be 2 or 3")
Assert(Y == 3 || U == 3 || V == 3, func_name+"One of the planes Y, U, V must be 3")
Assert(RadT == 1 || RadT == 2, func_name+"Temporal Radius of frame analysis must be 1 or 2")
Assert(Sharp >= 0 && Sharp <= 1, func_name+"Sharpening strength must be between 0 and 1.0")
Assert(PostMix >= 0 && PostMix <= 1, func_name+"The noise return value must be between 0 and 1.0")

dPlane = Y==3 && (U==3 || V==3) ? 4
\ : Y==3 && U==2 && V==2 ? 0
\ : Y==2 && U==3 && V==2 ? 1
\ : Y==2 && U==2 && V==3 ? 2
\ : Y==2 && U==3 && V==3 ? 3 : 4
pad = Max(Blksz, 8)
pel = 1
chr = U==3 || V==3 ? true : false

# denoising 1st way
dgLimit = input.neo_fft3d(sigma=Str, sigma2=Floor(Str*0.625), sigma3=Floor(Str*0.375), sigma4=Floor(Str*0.250), \
bt=RadT==1?3:5, Y=Y, U=U, V=V, bw=BlkSz*2, bh=BlkSz*2, ow=OLap, oh=OLap) #, ncpu=4, mt=true)
dgSpatD = mt_makediff(input, dgLimit, Y=Y, U=U, V=V)

# denoising 2nd way
dgNR1 = dgLimit.vsDeGrainMedian(modeY=0, limitY=Str, limitU=U==3?Str+2:0, limitV=V==3?Str+2:0)
dgNR1D = mt_makediff(input, dgNR1, Y=Y, U=U, V=V)

# combine 1st and 2nd ways
dgDD = mt_lutxy(dgSpatD, dgNR1D, "x range_half - abs y range_half - abs < x y ?", Y=Y, U=U, V=V, use_expr=2)
dgNR1x = mt_makediff(input, dgDD, Y=Y, U=U, V=V)

# sharpen the edges only
dgNR1x = Sharp > 0 ? mt_merge(dgNR1x, \
dgNR1x.RemoveGrain(17).Sharpen(Sharp), \
dgNR1x.RemoveGrain(12).mt_edge("prewitt", Y=3, U=2, V=2).mt_inpand(chroma="-128").Blur(1.58), \
Y=3, U=2, V=2)
\ : dgNR1x

# denoising 3rd way
sup = dgNR1x.Blur(1.58).Blur(1.58).MSuper(hpad=pad, vpad=pad, pel=pel, chroma=chr)
MultiVec = MAnalyse(sup, multi=true, delta=RadT, blksize=BlkSz, overlap=OLap, search=5, dct=7, chroma=chr, truemotion=false, global=true)
dgNR1xS = MSuper(dgNR1x, hpad=pad, vpad=pad, pel=pel, levels=1, chroma=chr)
dgNR2 = MDegrainN(dgNR1x, dgNR1xS, MultiVec, RadT, plane=dPlane)

# combine 1st, 2nd and 3rd ways
dgDD2 = mt_lutxy(dgNR1x, dgNR2, "x range_half - abs y range_half - abs < x y ?", Y=Y, U=U, V=V, use_expr=2)

# post denoising
# dgNR3 = dgDD2.RemoveGrain(17)
# dgDD2 = mt_lutxy(dgNR3, dgDD2, "x range_half - abs y range_half - abs < x y ?", Y=Y, U=U, V=V, use_expr=2)

# sharpening
allD = Sharp > 0 ? mt_makediff(input.Sharpen(1), dgDD2.Blur(1.58).Blur(1.58)) : NOP()
ssD = Sharp > 0 ? mt_makediff(dgDD2, dgDD2.RemoveGrain(20)) : NOP()
ssDD = Sharp > 0 ? mt_lutxy(ssD.Repair(allD, 12), ssD, "x range_half - abs y range_half - abs < x y ?", Y=Y, U=U, V=V, use_expr=2) : NOP()
out = Sharp > 0 ? mt_lutxy(dgDD2, ssDD, "x range_half y - "+String(Sharp)+" * -", Y=3, U=2, V=2, use_expr=2) : dgDD2

# dehaloing
m0 = Sharp > 0 && DeHalo ? dgNR1x.mt_edge("prewitt", Y=3, U=2, V=2).mt_inpand(chroma="-128") : NOP()
m1 = Sharp > 0 && DeHalo ? mt_lutxy(out, m0, "y range_half > x y ?", Y=3, chroma="-128", use_expr=2).mt_binarize(threshold=128).Blur(0.5) : NOP()
out = Sharp > 0 && DeHalo ? mt_merge(out, dgNR1x.Blur(0.1), m1, Y=3, U=2, V=2) : out

PostMix > 0 ? mt_lutxy(out, input, "x x y - "+String(PostMix)+" * -", Y=Y, U=U, V=V, use_expr=2) : out
}

kedautinh12
8th February 2023, 14:42
Can you share your slow ver??

Arx1meD
8th February 2023, 16:28
Can you share your slow ver??
This is the script from the first post of this thread.

anton_foy
9th February 2023, 07:42
I like everything in Temporaldegrainv2 and the quality of the cleaning of the noise is brilliant! But the speed of work is slow, and on my old computer it works very slowly. I decided to change the script so that it works faster and cleaned well from noise.
This is my lightweight version - Temporaldegrain2_fast.


@Arx1meD Actually it looks great! Faster and degrains smoothly while keeping a good amount of detail.

I will try to add mocomped temporalsoften instead of mdegrain just to see if it eats a bit more noise.

avinewbie
12th February 2023, 22:25
@Arx1meD
Thank you.I tried it and its amazingly fast and easy to tune even on my old PC.

rgr
22nd February 2023, 16:20
Why am I getting this error?

Both clips should have the same colorspace!
(C:/Program Files (x86)lAviSynth+/plugins64+/TemporalDegrain-v2.6.4.avsi, line 441)
(C:/Program Files (x86)lAviSynth+/plugins64+/TemporalDegrain-v2.6.4.avsi, line 395)

Source: MPEG2, 720x576, YUV420

Full script:
video_org=FFmpegSource2("../00000.m2ts", atrack=-1)
crop_left=12 # | rimozione esatta delle bande nere sinistra, sopra, destra e del disturbo sotto
crop_top=2 # | 720-(12+16)x576-(2+14)=692x560
crop_right=16
crop_bottom=14
video_org_crop=video_org.crop(crop_left,crop_top,-crop_right,-crop_bottom)

video_org_crop_adj=video_org_crop.ColorYUV(off_u=+12, off_v=-6)

### de-interlacing
deinterlaced=video_org_crop_adj.AssumeTFF().QTGMC(preset="slow", matchpreset="slow", matchpreset2="slow", sourcematch=3, tr1=2, tr2=1, NoiseTR=2, sharpness=0.1)

### convert to YV16
deinterlaced_yv16=deinterlaced.convertToYV16()

### denoising
denoised_yv16=deinterlaced_yv16.TemporalDegrain2(degrainTR=3)

### convert to YUY2
denoised=denoised_yv16.convertToYUY2()

### convert to YV12
denoised_yv12=denoised.convertToYV12()

### sharpening
sharpened_yv12=denoised_yv12.LSFmod(defaults="slow")

### convert to YUY2 with chroma from YUY2 color space
sharpened=sharpened_yv12.convertToYUY2().MergeChroma(denoised)

### add borders
video_restored=sharpened.addborders((crop_left+crop_right)/2,(crop_top+crop_bottom)/2,(crop_left+crop_right)/2,(crop_top+crop_bottom)/2)

return(video_restored)

rgr
22nd February 2023, 17:11
Feb 11, 2023: v2.6.4
- always undot before postFFT stage, increasing FFT efficiency by quite a bit when degrain was disabled
- mention suggested settings inside the script file

In the new version I get this error:

Both clips should have the same colorspace!
(C:/Program Files (x86)lAviSynth+/plugins64+/TemporalDegrain-v2.6.4.avsi, line 441)
(C:/Program Files (x86)lAviSynth+/plugins64+/TemporalDegrain-v2.6.4.avsi, line 395)

Rolling back to 2.6.3 solves the problem.

ErazorTT
24th February 2023, 19:24
Yes, I just updated the file. Should be fixed now.

ErazorTT
25th February 2023, 21:22
I found that there is a wierd inconsistent chroma shift for 420 sources. It can be upto half a pixel. Which means that when resized onto the luma, it will be twice of that.
From my investigation I found that it comes from mvtools MDegrain. I reported it here (https://github.com/pinterf/mvtools/issues/59), you can take a look of the magnitue of the deviation there.

I thus decided to go back to a single degrain step for the chroma. I think this is the best compromise in total.
This halfs the shift introduced by mvtools, which I think is good enough. And it gives quite some speed increase, at the expense of a slightly less clean chroma.
For the paranoid among us, a complete the circumvention of the chroma shift bug can be enabled by the flag "degrainAvoidChromaShift", but that is relatively expense at 10% performance cost.

Also, if it is really necessary to clean the chroma more, which should be rather rarely, both degrains steps can be enabled for the chroma by the flag "degrainChromaTwoStep". This will however also enable the relatively expensive circumvention of the bug.

karthauzi
3rd March 2023, 01:58
thanks for v2.6.6! Can it ported in G41fun.py Vapoursynth? Its actually v2.6.3

I have abolutely no Idea how to do this, even with googling, maybe i only need to adjust some lines? they are very different AVS and VS codelines.

Can you have a look into my G41Fun.rar to show us how to adjust it, so i can use v2.6.6?

Im using Staxrip and i already just Copy & Pasted the entire TemporalDegrain2 code from another G41fun.py into this one and replaced it from an old v2.4.3?. Improvising :D


https://drive.google.com/file/d/1uPauV40jfUKT8Xsq4bjkCJcUuBWpw3Jr/view?usp=sharing


Greetings

Mounir
14th March 2023, 00:01
I'm Trying the filter for the first time, i get an error (for a change) (tried v2.6.2 and v2.6.3 aswell)

avisource
convertoyv12()
TemporalDegrain2("CUDA"=false)

script error expected a , or )

poisondeathray
14th March 2023, 00:09
I'm Trying the filter for the first time, i get an error (for a change) (tried v2.6.2 and v2.6.3 aswell)


avisource
convertoyv12()
TemporalDegrain2("CUDA"=false)


script error expected a , or )


CUDA=false , no ""


TemporalDegrain2(CUDA=false)

kedautinh12
14th March 2023, 03:29
I'm Trying the filter for the first time, i get an error (for a change) (tried v2.6.2 and v2.6.3 aswell)



script error expected a , or )

Cuda parameter only use with postFFT=5. You can use without postFFT=5 but that parameter no meaning when don't set postFFT=5

Drommer
25th September 2023, 02:34
Hi. Is there any solution to the problem of color loss and artifacts when switching scenes? I saw in the manual about DCT, but it doesn't help and sometimes makes it worse.
I really like this filter. I have already found the optimal settings and transcode a few videos. Very reluctant to try anything else.

kedautinh12
25th September 2023, 05:06
Hi. Is there any solution to the problem of color loss and artifacts when switching scenes? I saw it in the manual about DCT, but it doesn't help and sometimes makes it worse.
I really like this filter. I have already found the optimal settings and transcribed a few videos. Very reluctant to try anything else.

I think it's related to banding colors after denoising, I think you can try parameter postFFT=3 or 4 or 5 to avoid banding. If banding continues after use 3, 4, and 5, you can try debanding with neo_f3kdb or gradfun3plus with 16bit

Example:

* Denoiser scripts
ConvertBits(16)
GradFun3plus(thr=0.25, radius=10, mask=2, smode=0,UV=1)

Drommer
25th September 2023, 13:29
I think it's related to banding colors after denoising
No, it's not about banding. This problem was discussed two pages ago. The last frame of the previous scene and the first frame of the next scene have distorted colors and spots. In this case (screenshots below) both processed frames go to cold tones, the second frame also has a small pink spot right of the door that gets bigger as the grainLevel increases.

https://imgsli.com/MjA5MTQx
https://imgsli.com/MjA5MTQy

P.S. My line: grainLevel=0, meBlksz=4, postFFT=4. I have also tried postFFT=0 and other options, but it has no effect.

Drommer
26th September 2023, 01:52
Just in case, I checked the script version - everything is fine, 2.6.6. I also update all other components the script might depend on.

I went back to the discussion on the previous pages and noticed a post where the problem was solved by changing the values of ppSCD1 and thSCD2. This works, but I had to reduce the values to ppSCD1=2 and thSCD2=80. I think such an extremely low value would lead to false positives within the same scene. Am I the first to experience this problem after the fixes in version 2.3.3?

UPD 27/09. I did some more tests. I tried using the SceneCutSelectClip (https://forum.doom9.org/showthread.php?p=1990796#post1990796) function, which (as I understand it) uses the same mechanism of searching and comparing frames. With default settings (thSCD1=400, thSCD2=130) scene change detection works correctly.

Drommer
27th September 2023, 01:30
I found a bug when using postFFT=4 (KNLMeansCL). The devId variable is ignored because it is not specified in the function call. It is necessary to fix line 513 as follows:
output = KNLMeansCL(temp, a=a, d=d, h=strength, device_id=device_id, channels=channels)

ErazorTT
5th January 2024, 14:47
So this is mainly visible on skin colors, right? This is at least what I get from your screenshots. I will try to find examples myself.

Concerning the SCD values. By driving them down you basically disabled the scene change detection for MVTools. This also suggests that it is an issue related to MDegrain. If thats the case, I fear there is not much that can be done, apart from informing the creators of MVTools.

Oh, and I pushed a new version which fixes the forwarding of the device_id for KNLMeans.

rgr
29th February 2024, 13:19
Are there any plans to fix issues like the one at the top of this screenshot?

https://i.imgur.com/CqqyqYu.png

takla
1st March 2024, 03:25
Are there any plans to fix issues like the one at the top of this screenshot?

https://i.imgur.com/CqqyqYu.png

Uhm, you want to crop black bars before denoising...

poisondeathray
1st March 2024, 03:46
That probably has more to do with QTGMC. Use border=true

ErazorTT
1st March 2024, 08:47
Are there any plans to fix issues like the one at the top of this screenshot?

Well, I‘ve never seen this before, and I myself am using this plugin on an almost daily basis. So, no until now it was not planned to fix this, since I was not aware of this issue.
Might that be the cause:
That probably has more to do with QTGMC. Use border=true

And if not, what kind of source is it? Is it interlaced and what other plugins are you using?

rgr
1st March 2024, 11:55
Uhm, you want to crop black bars before denoising...

Sometimes this is impossible (e.g. image with borders)

That probably has more to do with QTGMC. Use border=true

QTGMC is resistant to this (the problem appeared after adding TD2). I think I even saw a workaround for this in the QTGMC code, but I'm not sure.

Well, I‘ve never seen this before, and I myself am using this plugin on an almost daily basis. So, no until now it was not planned to fix this, since I was not aware of this issue.
Might that be the cause: (QTGMC)

And if not, what kind of source is it? Is it interlaced and what other plugins are you using?

Source: progressive(*), after QTGMC (InputType=1)

Boulder
1st March 2024, 12:33
Source: interlaced, after QTGMC (InputType=1)

InputType=x expects progressive input, it is not for deinterlacing.