From Avisynth wiki
Jump to: navigation, search
Author Didée, Sagekilla, Vit, real.finder, ErazorTT
Version 2.6.6
Download TemporalDegrain-v2.6.6.avsi
Category Denoisers
License Public Domain
Discussion Doom9 Thread


[edit] Description

This script builds on Temporal Degrain but it is able to clean the noise even further while impoving the sharpness in cases where orignal version had severe drops in visual quality.

Comparing to the original version there are improvements in the motion estimation by using the exceptional approach of QTGMC and an optional final step of FFT and dithering to further smooth the output. The performance will be especially better in regions of low contrast and diverging movement where the very mushy intermediate stream was losing motion vectors thus smearing the output considerably.

The result can be completely noiseless, perfectly sharp, much better compressable, without introducing any banding while still yielding a very natural look.

[edit] Requirements

[edit] Required Plugins

Latest versions of the following filters are recommended unless stated otherwise.

[edit] Optional Plugins

[edit] Usage

Suggested settings for removing the grain, sorted by increasing source grain
degrainTR=0,postFFT=0 (aka Undot)
degrainTR=0,postFFT=1,postSigma=value between 0 and 1
degrainTR=1,grainLevel=0,postFFT=1,postSigma=value between 0 and 1
degrainTR=1,grainLevel=1,postFFT=1,postSigma=value between 0 and 2
degrainTR=1,grainLevel=2,postFFT=1,postSigma=value between 0 and 2
degrainTR=2,grainLevel=2,postFFT=1,postSigma=value between 0 and 2
degrainTR=2,grainLevel=3,postFFT=1,postSigma=value between 0 and 2

Any degrainTR above 0 not work for very fast-paced films with many particles flying around (explosions, rain). In this case only this setting will work:
degrainTR=0,postFFT=1,postSigma=value between 0 and 4

Recommendations to be followed in case you want to find you own settings:
1. start with default settings
2. if less denoising is needed set grainLevel to 0, if you need more degraining start over reading at next paragraph
3. if you need even less denoising:
- EITHER: set outputStage to 1 or even 0 (faster)
- OR: use the postMix setting and increase the value from 0 to as much as 100 (slower)

Recommendations for strong degraining:
1. start with default settings
2. search the noisiest* patch of the entire movie, enable grainLevelSetup (=true), zoom in as much as you can and prepare yourself for pixel peeping. (*it really MUST be the noisiest region where you want this filter to be effective)
3. compare the output on this noisy* patch of your movie with different settings of grainLevel (0,1,2) and use the setting where the noise level is lowest (irrespectable of whether you find this to be too much filtering).
- If multiple grainLevel settings yield comparable results while grainLevelSetup=true and observing at maximal zoom be sure to use the lowest setting! If you're unsure leave it at the default (2), your result might no be optimal, but it will still be great.
4. disable grainLevelSetup (=false), or just remove this argument from the function call. Now revert the zoom and look from a normal distance at different scenes of the movie and decide if you like what you see.
5. if more denoising is needed try postFFT=1 with postSigma=1, then tune postSigma (obvious blocking and banding of regions in the sky are indications of a value which is at least a factor 2 too high)
6. if you would need a postSigma of more than 2, try first to increase degrainTR to 2. The goal is to balance the numerical values of postSigma and degrainTR, some prefer more simga and others more TR, it's up to you. However, do not increase degrainTR above 1/8th of the fps (at 24fps up to 3).
7. if you cranked up postSigma higher than 3 then try postFFT=3 instead. Also if there are any issues with banding then try postFFT=3, then perhaps in combination with negative values of postDither.
8. if the luma is clean but you still have visible chroma noise then you can adjust postSigmaC which will separately clean the chroma planes (at a considerable amount of processing speed).

Use only the following knobs (all other settings should already be where they need to be):
- degrainTR (1), temporal radius of degrain, usefull range: min=default=1, max=fps/8. Higher values do clean the video more, but also increase probability of wrongly identified motion vectors which leads to washed out regions
- grainLevel (2), if input noise level is relatively low set this to 0. The right setting must be found using grainLevelSetup=true while all other settings are at default. Set this setting such that the noise level is lowest.
- grainLevelSetup (false), only to be used while finding the right setting for grainLevel. This will skip all your other settings!
- postFFT (0), if you want to remove absolutely all remaining noise suggestion is to use 1 (ff3dfilter) or for slightly higher quality at the expense of much worse speed 3 (dfttest). 2, 4 and 5 are GPU based versions.
- postSigma (1), increase it to remove all the remaining noise you want removed, but do not increase too much since unnecessary high values have severe negative impact on either banding and/or sharpness
- postDither (2), higher values produce higher output quality (less introduced banding and noise), while more negative values combat preexisting banding and must be used together with postFFT 3
- degrainPlane (4), if you just want to denoise only the chroma use 3 (this helps with compressability while the clip is almost identical to the original)
- outputStage (2), if the degraining is too strong, you can output earlier stages
- postMix (0), if the degraining is too strong, increase the value going from 0 to 100
- fftThreads (1), usefull if you have processor cores to spare, increasing to 2 will probably help a little with speed (more performace is gained if additonally this script is run in MT_MULTI_INSTANCE mode with a prefetch of at least half of your cores)
- postSigmaC (=postSigma), if chroma needs more cleanup than luma, increase this above postSigma, could be 2 to 8 times as high as postSigma.

[edit] Changelog

May 15, 2018: v2.0
- use the exceptional motion estimation from QTGMC
- use MDegrainN for unbound temporal radius
- automatic tuning of default parameters based on input size
- add optional motion compensated post processing FFT filtering

Oct 19, 2018: v2.0.1
- rename function to TemporalDegrain2
- expose TrueMotion parameter through meTM, and let it default to false

Oct 22, 2018: v2.0.2
- use power of 2 blocksizes for MAnalyse which have much better performance
- check that Undot exists before calling it

Oct 23, 2018: v2.0.3
- use RemoveGrain(1) instead of Undot

Oct 26, 2018: v2.1
- tune motion estimation

Oct 27, 2018: v2.1.1
- allow for a controlled over-sharpen through extraSharp
- correct parameter types

Oct 30, 2018: v2.1.2
- correct usage of KNLMeansCL
- update comments

Nov 03, 2018: v2.1.3
- another try to fix KNLMeansCL
- expose KNLMeansCL device id through knlDevId

Nov 19, 2018: v2.1.4
- minor updates to code comments

Dec 26, 2018: v2.1.5
- convert TV range to PC range in search clip, improving motion estimation

Dec 27, 2018: v2.1.6
- tweaked parameters for higher noise removal

Dec 27, 2018: v2.1.7
- settings depening on input noise level, flag must be set manually
- add post processing behaviour of TemporalDegrain v1.23 to postFFT=-1
- change defaults and rewrite recommendations

Jan 02, 2019: v2.2
- high bit support, native "double width" format not "stacked" format
- currently just postFFT=0, 1 and 4 are supported for high bit

Feb 24, 2019: v2.2.1
- swap deprecated use of ConvertToXbit by ConvertBits
- relaxed settings for scene change detection, was too aggressive

Apr 12, 2019: v2.2.2
- refine input size categorization

Feb 02, 2021: v2.2.3
- rescale SAD/SCD thresholds when DCT is switched from SAD to SATD
- allow change of motion estimation also based on chroma (meChroma)

Feb 02, 2021: v2.2.4
- use optional high bitdepth processing for FFT3DGPU
- added postMix setting do be able to degrease filter strength

Feb 02, 2021: v2.2.5
- use neo fft
- add optional high bitdepth processing for dfttest

Feb 05, 2021: v2.2.6
- correct scaling for DCT=5 and set it as default

Feb 07, 2021: v2.3.0
- use native high bit format also for KNLMeansCL
- scale sigma of FFT3DGPU
- grainLevel is now interger range 0-2
- make setup of grainLevel easier by using parameter grainLevelSetup=true
- provide user with the choice which stage of the pipeline to output (outputStage)

Feb 07, 2021: v2.3.1
- tune grainLevel 1 to fit more centrally between 0 and 2
- reorganize arguments by importance

Dec 16, 2021: v2.3.2
- go back to using SAD (DCT=0) instead of SATD, since SATD appears to make more harm then helping
- tweak usages of FFT3DGPU to match the FFT3DFilter usages (thanks goes to Tenkei)
- HQdn3D does now support high bitdepth
- KNLMeansCL correct sigma to match the other filters (factor 2 higher then before)

Dec 19, 2021: v2.3.3
- set thSADC to be half of thSAD, since changes in chroma are usually smaller than in luma

Dec 20, 2021: v2.3.4
- dithering is delayed to after contraSharpending which increases quality of dithering, decreasing banding and noise (postDither=2), old behaviour is regained with postDither=1
- postDither argument has been inverted! [new postDither = (-1) * old postDither]

Dec 21, 2021: v2.4.0 (This and later releases need AviSynth 3.7.1+)
- add BM3D_CPU & BM3D_CUDA (based on BM3D prefilter of Dogway's SMDegrain) and mods by kedautinh12 (Aug 12 - Dec 19)

Dec 21, 2021: v2.4.1
- small speed increase for BM3D (thanks to kedautinh12)

Jan 05, 2022: v2.4.2
- allow enabling or disabling of chroma and luma filtering for BM3D (thanks to kedautinh12)
- allow denoising on different planes at the two stages (degrainPlane vs postPlane)

Feb 15, 2022: v2.4.3
- add limit r to 3 when CUDA=true for BM3D (based on BM3D prefilter of Dogway's SMDegrain) and mods by kedautinh12
- add preset for BM3D (based on BM3D prefilter of Dogway's SMDegrain) and mods by kedautinh12

Apr 05, 2022: v2.5.0
- allow distinct postFFT and postSigma for luma and chroma

May 01, 2022: v2.6.0
- clean chroma more by also using the first degrain step
- tweak scene change detection factors

May 02, 2022: v2.6.1
- fix grainLevelSetup which was broken in previous release

May 10, 2022: v2.6.2
- some fixes and cleanup

Jun 06, 2022: v2.6.3
- increase possible range of grainLevel
- allow for multiple usages of this script

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

Feb 28, 2023: v2.6.6
- cleaning chroma only in one step, to ameliorate the chroma shift bug in mvtools MDegrain

Personal tools