Vapoursynth SmoothGrad

From wiki.selur.net
Revision as of 05:09, 15 November 2026 by Selur (talk | contribs) (New filter page (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

SmoothGrad reduces banding in flat areas and gentle gradients with a large box blur that is only kept where it changes the picture little, so edges stay intact.

Filtering → Vapoursynth → DeBand

SmoothGrad controls in Hybrid
SmoothGrad controls in Hybrid

What it does

The picture is blurred with a box blur and compared with the original pixel by pixel. Differences up to Threshold take the blurred value; between Threshold and Threshold × Elast the blur is phased out gradually; larger differences (edges, detail) keep the original.

Settings

Control Parameter Range / values Hybrid default Meaning
Radius radius 2 – 9 9 Size of the averaged square: radius × 2 − 1 pixels (9 = 17×17).
Threshold thr 0.01 – 1.00 0.25 Largest difference that is fully accepted, in 8-bit units at any bit depth.
Elast elast 1.00 – 100.00 3 Soft threshold: differences up to Threshold × Elast are blended; 1 = hard threshold.
Planes planes all, chroma only, luma only all Planes that are filtered; the others are copied unchanged.
Tools: Expr – akarin, cranexpr, std akarin Expression plugin; akarin needs AVX2.
Tools: BoxBlur – vszip, std vszip Box blur implementation.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356):

# adjusting color using SmoothGrad
clip = color.SmoothGrad(clip, tools={'expr': 'akarin', 'boxblur': 'vszip'})

How Hybrid calls it

  • SmoothGrad works on any bit depth, integer or float, YUV or RGB; no conversion is needed.
  • The threshold is passed as entered; the script scales it from 8-bit to the clip's range.
  • Values are only written when they differ from the defaults, which are the script's own.
  • In the default filter order SmoothGrad runs with the color filters, before denoising, unlike the other debanders; the filter queue can change the order.
  • SmoothGrad also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

Origin

SmoothGrad comes from the Dither package for AviSynth; the VapourSynth version is based on muvsfunc's port, a box blur followed by a limiting step. For several SmoothGrad passes in a row the original recommends the source as reference clip; Hybrid does not offer a reference clip. GradFun3Mod can use SmoothGrad as its multi-stage smoothing.

Sources