Vapoursynth AutoChromaFix: Difference between revisions
New page: AutoChromaFix (via create-page on MediaWiki MCP Server) |
Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 28: | Line 28: | ||
== Example == | == Example == | ||
Measuring every frame, without the on-screen display, on a 10-bit YUV 4:2:0 source: | Measuring every frame, without the on-screen display, on a 10-bit YUV 4:2:0 source: | ||
< | <pre> | ||
# Correcting chroma alignment using AutoChromaFix | # Correcting chroma alignment using AutoChromaFix | ||
clip = autoChromaFix.AutoChromaFix(clip, nodisplay=True) | clip = autoChromaFix.AutoChromaFix(clip, nodisplay=True) | ||
</ | </pre> | ||
== How Hybrid calls it == | == How Hybrid calls it == | ||
| Line 43: | Line 43: | ||
=== The script === | === The script === | ||
The function only uses VapourSynth core functions: <code>std.Prewitt</code> for the edge masks, <code>resize.Bicubic</code> for the trial shifts, <code>std.PlaneStats</code> to score each shift and <code>text.Text</code> for the display. When two shifts score the same, the smaller one wins. | The function only uses VapourSynth core functions: <code>std.Prewitt</code> for the edge masks, <code>resize.Bicubic</code> for the trial shifts, <code>std.PlaneStats</code> to score each shift and <code>text.Text</code> for the display. When two shifts score the same, the smaller one wins. | ||
== Sources == | == Sources == | ||
Latest revision as of 09:47, 16 November 2026
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

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
- VapoursynthScriptsInHybrid (the script collection Hybrid uses)
- VapourSynth documentation: std.Prewitt
- Hybrid's tooltips