Vapoursynth AutoChromaFix

From wiki.selur.net
Revision as of 19:35, 14 November 2026 by Selur (talk | contribs) (Remove background without information (via update-page on MediaWiki MCP Server))
Jump to navigation Jump to search

AutoChromaFix measures how far the color planes (U and V) are shifted against the brightness (luma) and moves them back into place. It is meant for sources whose colors sit slightly next to the outlines, which is common with anime and cartoons.

Filtering → Vapoursynth → Color → Chroma

AutoChromaFix controls in Hybrid
AutoChromaFix controls in Hybrid

What it does

The filter builds an edge mask of the luma (scaled down to the size of the chroma planes, taking the chroma siting into account) and compares it with edge masks of U and V at different trial shifts. A coarse search tries whole pixels, a fine search then refines the best match. The shift with the smallest difference is applied to U and V.

The measurement can be done once on a reference frame and used for the whole clip, or on every frame. The search is slow, especially per frame.

Settings

Control Parameter Range Hybrid default Meaning
Reference frame referenceframe -1 – 64 -1 0 or more: measure this frame once and use its shift for the whole clip. -1: measure every frame (much slower).
Max. shift maxshift 1 – 4 2 Largest shift that is searched for, in chroma pixels (2 luma pixels for 4:2:0). The coarse search grows with the square of this value.
Accuracy accuracy 0.05 – 1 0.25 Step of the fine search; 0.25 means quarter-pixel accuracy. The fine search always covers at least ±0.5 pixel around the best whole-pixel match, so smaller values are finer but slower.
no display nodisplay on/off off When off, the measured U and V shifts are drawn into the picture. Switch it on for encoding.
no fix nofix on/off off Only measure (and display), do not correct.

Example

Measuring every frame, without the on-screen display, on a 10-bit YUV 4:2:0 source:

# Correcting chroma alignment using AutoChromaFix
clip = autoChromaFix.AutoChromaFix(clip, nodisplay=True)

How Hybrid calls it

  • AutoChromaFix works on 8–16-bit integer YUV.
  • Interlaced sources are deinterlaced or split into fields before the filter.
  • Only values that differ from the defaults are written.
  • With the default no display off, the measured values end up in the encode; tick no display for the final encode.
  • AutoChromaFix also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

The function only uses VapourSynth core functions: std.Prewitt for the edge masks, resize.Bicubic for the trial shifts, std.PlaneStats to score each shift and text.Text for the display. When two shifts score the same, the smaller one wins.

Sources