Vapoursynth RainbowSmooth

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

RainbowSmooth is a small spatial derainbower: it smooths the chroma with SmoothUV and applies a stronger smoothing at edges, where rainbows and color bleeding appear.

Filtering → Vapoursynth → DeRainbow

RainbowSmooth controls in Hybrid
RainbowSmooth controls in Hybrid

What it does

An edge mask is built from the luma. The chroma is smoothed with the low threshold everywhere (or not at all at 0) and with the high threshold at the edges; the mask merges the two. If the low threshold is not below the high one, no mask is built and only the low smoothing is used (fastest). The luma is never changed.

Requirements

  • SmoothUV is x86 only; there is no native ARM build.

Settings

Control Parameter Range / values Hybrid default Meaning
Radius radius 1 – 7 3 SmoothUV radius; larger smooths more.
Threshold (low) lthresh 0 – 450 0 Chroma smoothing everywhere; 0 = only the edge smoothing.
Threshold (high) hthresh 0 – 450 220 Chroma smoothing at the edges selected by the mask.
Mask mask original, prewitt, sobel, tcanny, fast_sobel, kirsch, retinex_edgemask original Edge mask; original is the mask of the AviSynth function (luma max–min difference).
Tools: Expr – akarin, cranexpr, std akarin Expression evaluator for original, fast_sobel, kirsch and retinex_edgemask; akarin needs an AVX2 CPU, otherwise std.
Tools: BoxBlur – vszip, std vszip Blur of retinex_edgemask when TCanny is std.
Tools: EdgeMasks – edgemasks, std std Edge detection for prewitt, sobel and kirsch, and for retinex_edgemask when TCanny is std.
Tools: TCanny – tcanny, std std Edge detection of retinex_edgemask; std uses a box blur and Sobel instead.

The tcanny mask always uses the tcanny plugin.

Example

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

clip = core.std.AddBorders(clip=clip, left=0, right=0, top=6, bottom=6) # add borders to achieve mod 16 (vsRainbowSmooth) - 640x368
# adjusting color space from YUV420P10 to YUV444P8 for vsRainbowSmooth
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, dither_type="error_diffusion")
# rainbow removal using RainbowSmooth
clip = RainbowSmooth.RainbowSmooth(clip, tools={'expr': 'akarin', 'boxblur': 'vszip', 'edgemasks': 'std', 'tcanny': 'std'})
clip = core.std.Crop(clip=clip, left=0, right=0, top=6, bottom=6) # removing added borders from mod requirement (vsRainbowSmooth) -  640x356

How Hybrid calls it

  • RainbowSmooth works on 8-bit YUV only (any subsampling); higher bit depths are converted to 8 bit first. Width and height must be mod 16.
  • The thresholds are passed as they are, since the filter runs in 8 bit.
  • Hybrid loads the plugins the chosen mask and tools need.
  • Values are only written when they differ from the defaults.
  • RainbowSmooth is also part of the custom chain "DeRainbow - RainbowSmooth".
  • RainbowSmooth also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

SmoothUV and rainbow_smooth

SmoothUV is a chroma-only spatial derainbow filter ported from the AviSynth plugin (without the SSHiQ part); its own default threshold is 270. RainbowSmooth is a port of the AviSynth function rainbow_smooth(); the extra masks fast_sobel, kirsch and retinex_edgemask originally came from kagefunc. In a script a custom mask clip can be passed, which Hybrid does not offer.

Sources