Vapoursynth FixChromaBleeding: Difference between revisions

From wiki.selur.net
Jump to navigation Jump to search
New page: FixChromaBleeding (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 30: Line 30:
== Example ==
== Example ==
Default settings on a 10-bit YUV 4:2:0 source:
Default settings on a 10-bit YUV 4:2:0 source:
<syntaxhighlight lang="python">
<pre>
# Fixing chroma bleeding using FixChromaBleedingMod
# Fixing chroma bleeding using FixChromaBleedingMod
clip = chromaBleeding.FixChromaBleedingMod(clip, tools={'expr': 'akarin'})
clip = chromaBleeding.FixChromaBleedingMod(clip, tools={'expr': 'akarin'})
</syntaxhighlight>
</pre>


== How Hybrid calls it ==
== How Hybrid calls it ==
Line 44: Line 44:
=== The script ===
=== The script ===
The function is a port of FixChromaBleedingMod from havsfunc, simplified: the mask is the distance of the boosted V plane from neutral gray, inflated once; the shifted copy is made with <code>resize.Spline16</code> and the saturation changes with the Tweak function of the same script collection. The planes are combined with <code>std.MaskedMerge</code>.
The function is a port of FixChromaBleedingMod from havsfunc, simplified: the mask is the distance of the boosted V plane from neutral gray, inflated once; the shifted copy is made with <code>resize.Spline16</code> and the saturation changes with the Tweak function of the same script collection. The planes are combined with <code>std.MaskedMerge</code>.
=== VapourSynth ===
Not a core filter; the VapourSynth documentation has no page for it.


=== AviSynth ===
=== AviSynth ===
FixChromaBleeding exists as a user script for AviSynth; the AviSynth+ documentation has no page for it.
FixChromaBleeding exists as a user script for AviSynth.


== Sources ==
== Sources ==

Latest revision as of 09:49, 16 November 2026

FixChromaBleeding reduces color bleeding, oversaturation and color shifts, mainly in strongly red and blue areas, as they often appear on analog sources such as VHS.

Filtering → Vapoursynth → Color → Chroma

FixChromaBleeding controls in Hybrid
FixChromaBleeding controls in Hybrid

What it does

  1. A mask of the affected areas is built from the V (red-difference) plane after boosting the saturation by Threshold; optionally the mask source is blurred first.
  2. A copy of the clip is shifted by Shift (h/v) and its saturation is changed by Strength.
  3. Inside the mask, the U and V planes of the original are replaced by those of the shifted copy. Luma stays unchanged.

Settings

Control Parameter Range Hybrid default Meaning
Shift (h) cx -16 – 16 4 Horizontal shift of the chroma copy in luma pixels; positive moves the chroma to the left.
Shift (v) cy -16 – 16 4 Vertical shift of the chroma copy in luma pixels; positive moves the chroma up.
Threshold thr 0 – 255 4.00 Saturation boost before the mask is taken; higher values mark more of the picture as bleeding.
Strength strength 0 – 10 0.80 Saturation of the shifted chroma copy: below 1 desaturates, 1 keeps, above 1 boosts the color.
Blur blur on/off off Blurs the mask source with a 3×3 kernel.
Tools: Expr tools akarin, cranexpr, std akarin (std without AVX2) Expression evaluator used inside the script.

Example

Default settings on a 10-bit YUV 4:2:0 source:

# Fixing chroma bleeding using FixChromaBleedingMod
clip = chromaBleeding.FixChromaBleedingMod(clip, tools={'expr': 'akarin'})

How Hybrid calls it

  • FixChromaBleeding works on 8–16-bit integer YUV; the mask is computed at the clip's bit depth.
  • Interlaced sources are deinterlaced or split into fields before the filter.
  • Shifts, Threshold, Strength and Blur are only written when they differ from the defaults; the Tools choice is always written.
  • FixChromaBleeding also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

The function is a port of FixChromaBleedingMod from havsfunc, simplified: the mask is the distance of the boosted V plane from neutral gray, inflated once; the shifted copy is made with resize.Spline16 and the saturation changes with the Tweak function of the same script collection. The planes are combined with std.MaskedMerge.

AviSynth

FixChromaBleeding exists as a user script for AviSynth.

Sources