Vapoursynth LUTDeRainbow

From wiki.selur.net
Revision as of 04:40, 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

LUTDeRainbow is Scintilla's temporal rainbow remover: where the previous and the next frame agree, the chroma is blended with their average.

Filtering → Vapoursynth → DeRainbow

LUTDeRainbow controls in Hybrid
LUTDeRainbow controls in Hybrid

What it does

For each pixel the chroma (and optionally the luma) of the previous and the next frame are compared. If they differ less than the thresholds, the pixel counts as static and its chroma becomes a 50/50 blend of the current chroma and the neighbors' average. Moving areas are left alone.

Settings

Control Parameter Range / values Hybrid default Meaning
Chroma threshold cthresh 0 – 255 10 Largest chroma difference between previous and next frame for a pixel to be treated. Higher catches more rainbows but risks artifacts; stay below about 20.
Luma threshold (checkbox) y on/off on The luma difference between previous and next frame must be small as well.
Luma threshold (value) ythresh 0 – 255 10 Like the chroma threshold, for luma; only available while the checkbox is on.
Link UV linkUV on/off on On: a pixel is changed only when both U and V pass (one shared mask). Off: separate masks for U and V.
Mask mask on/off off Shows the combined U/V mask instead of the video, to tune the thresholds; only available with Link UV on.
Tools: Expr – akarin, cranexpr, std akarin Expression evaluator; akarin needs an AVX2 CPU, otherwise std is used.

Example

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

# rainbow removal using LUTDeRainbow
clip = derainbow.LUTDeRainbow(clip, tools={'expr': 'akarin'})

How Hybrid calls it

  • LUTDeRainbow works on 8–16-bit integer YUV; other formats are converted first. It is frame-based, so interlaced material should be deinterlaced before it.
  • Thresholds are given on the 8-bit scale; the script scales them to the bit depth (10 becomes 40 at 10 bit).
  • The comparisons are strict, so a threshold of 0 treats no pixels.
  • Values are only written when they differ from the defaults; the luma threshold only while Luma threshold is on.
  • With Mask on, the output is gray (8 bit for 8-bit sources, 16 bit otherwise).
  • LUTDeRainbow also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

LUTDeRainbow started as a MaskTools2 script for AviSynth and was ported to VapourSynth in havsfunc, which stopped at 10 bit. The version Hybrid uses combines the masks with expressions above 10 bit and so works up to 16 bit. The original author calls it reasonably fast: faster than aWarpSharp, slower than DeGrainMedian.

Sources