Vapoursynth MLDegrain

From wiki.selur.net
Jump to navigation Jump to search

MLDegrain ("Multi-Level MDegrain") by Didée removes large, dancing grain: it denoises a strongly downscaled copy first, where motion compensation is very stable, and then works back up to the original size.

Filtering → Vapoursynth → DeGrain

MLDegrain controls in Hybrid
MLDegrain controls in Hybrid

What it does

The clip is scaled down twice (original → medium → small). MDegrain runs on the small copy; then each larger level only degrains the residual that the smaller level could not see. Block size, subpixel accuracy and truemotion are chosen per level from its width. The filter is slow at HD sizes.

Settings

Control Parameter Range Hybrid default Meaning
Scale (org/med) scale1, scale2 1 – 10 1.50 / 2.00 Downscale factors from original to medium and from medium to small.
Threshold thSAD 1 – 1024 400 Degrain SAD threshold.
Strength tr 1 – 3 3 Frames on each side used for degraining.
Recalculate rec on/off off Refine the vectors with half the block size.
Chroma chroma on/off on Degrain the chroma planes too.
Soft (small/med/org) soft 0 – 1 each 0 / 0 / 0 Above 0 that level degrains a blurred clip with motion search on a sharpened copy: light sharpening where the motion match is good, light blurring where it is bad.
Tools: MV tools mvutensils, mv, mvgpu mvutensils (mvgpu with a discrete GPU on R82) Motion vector implementation.
Tools: Expr / Median tools akarin, cranexpr, std / zsmooth akarin / zsmooth Expression evaluator; the median is only used with a Soft value above 0.

Example

Default settings on a 10-bit YUV 4:2:0 source:

# removing grain using MLDegrain
clip = degrain.MLDegrain(clip, tools={'mv': 'mvutensils', 'expr': 'akarin', 'median': 'zsmooth'})

How Hybrid calls it

  • MLDegrain works on 8–16-bit integer YUV and gray clips.
  • All values are only written when they differ from the defaults; the Tools choice is always written.
  • MLDegrain also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

AviSynth

Didée posted MLDegrain in 2011 in a doom9 thread about dancing noise; his version used MCDegrain with three frames and thSAD 480 on every level, with soft on the small and the original level, and suggested pel 2 on the smallest scale and pel 1 on the original.

Sources