Vapoursynth RGBAdjust

From wiki.selur.net
Revision as of 09:50, 16 November 2026 by Selur (talk | contribs) (Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

RGBAdjust changes the red, green and blue channels separately: a gain (scaling), an offset (bias) and a gamma curve per channel. Typical uses are fixing color casts and adjusting the white balance by hand.

Filtering → Vapoursynth → Color → Grading

RGBAdjust controls in Hybrid
RGBAdjust controls in Hybrid

What it does

For each channel the value is first multiplied by Scaling and shifted by Bias, then bent by Gamma. With all values at their defaults (1 / 0 / 1) the picture is unchanged. The clip is processed in RGB.

Settings

Control Parameter Range Hybrid default Meaning
Scaling (R/G/B) r, g, b 0 – 255 1.000 Multiplies the channel (r = 3 triples red).
Bias (R/G/B) rb, gb, bb -255 – 255 0.000 Fixed value added to the channel, on the 8-bit scale.
Gamma (R/G/B) rg, gg, bg 0.01 – 255 1.000 Gamma per channel; > 1 brightens, < 1 darkens.
Tools: Expr tools akarin, cranexpr, std akarin (std without AVX2) Expression evaluator used inside the script.

Example

A slightly warmer picture (red × 1.05, blue × 0.95) on a 10-bit YUV 4:2:0 source:

# adjusting color space from YUV420P10 to RGB30 for vsRGBAdjust
clip = core.resize.Bicubic(clip=clip, format=vs.RGB30, matrix_in_s="470bg", range_in_s="limited", range_s="full")
# color adjustment using RGBAdjust
clip = color.RGBAdjust(clip, r=1.050, b=0.950, tools={'expr': 'akarin'})
# adjusting output color from RGB30 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_in_s="full", range_s="limited")

How Hybrid calls it

  • RGBAdjust works on integer RGB; Hybrid converts the clip to RGB first, if it isn't RGB already.
  • Only values that differ from the defaults are written to the script.
  • The bias is entered on the 8-bit scale; the script scales it to the clip's bit depth (255 becomes the format's maximum, e.g. a bias of 20 adds about 80 at 10 bit).
  • RGBAdjust also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

The VapourSynth version is a script function based on a VideoHelp forum post by _Al_. It only accepts RGB clips, reads the clip's range flag (RGB without one counts as full range), applies gain and bias together with one expression and then gamma per plane with std.Levels.

VapourSynth

The gamma step uses std.Levels, see Levels.

AviSynth (RGBAdjust)

AviSynth's RGBAdjust has the same parameter names and order of operations (gain, bias, gamma, then clipping). Its gains are scaled to the bit depth automatically, its bias values are not (the user multiplies them, e.g. ×4 for 10 bit) — Hybrid's VapourSynth version does that scaling itself. AviSynth adds analyze (channel statistics), dither and per-frame values (conditional). See Avisynth RGBAdjust.

Sources