Vapoursynth DeHalo alpha

From wiki.selur.net
Jump to navigation Jump to search

DeHalo_alpha reduces bright and dark halos around edges, typically left by oversharpening. Dark and bright halos can be treated with different strength.

Filtering → Vapoursynth → DeHalo

DeHalo_alpha controls in Hybrid
DeHalo_alpha controls in Hybrid

What it does

A blurred reference is made by downscaling the luma by the radius and scaling it back up. The local contrast of the source and of the reference is compared, and where the difference looks like a halo, the source is replaced by the blurred picture. The sensitivity window decides how weak a change must be to be fully accepted and how strong to be fully discarded. Only luma is processed; chroma passes through unchanged.

Settings

Control Parameter Range / values Hybrid default Meaning
Radius (X/Y) rx / ry 1 – 10 2.0 / 2.0 Horizontal and vertical halo radius. Keep it as low as possible; too high misses small spots.
Strength (dark/bright) darkstr / brightstr −10 – 10 1.0 / 1.0 How strongly dark and bright halos are removed; 1.0 is symmetrical. For anime a dark strength of 0.4 – 0.8 can be better.
Sensitivity (low) lowsens 0 – 1000 50 Lower end of the window (8-bit scale): weaker changes are fully accepted.
Sensitivity (high) highsens 0 – 1000 50 Upper end of the window and strength modifier for borders (used as a percentage).
Sampling ss 1 – 16 1.5 Supersampling factor to avoid aliasing; at 1 a Repair step limits the result instead.
Tools: Expr tools akarin, cranexpr, std akarin (std without AVX2) Expression evaluator.
Tools: RG tools zsmooth, neo_smo zsmooth Repair implementation; only used when Sampling is 1.

Example

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

# applying dehalo using DeHalo_alpha
clip = dehalo.DeHalo_alpha(clip, tools={'expr': 'akarin', 'rg': 'zsmooth'})

How Hybrid calls it

  • DeHalo_alpha works on 8–16-bit integer YUV clips; float and RGB sources are converted first.
  • Values are only written when they differ from the defaults; the Tools selection is always written.
  • Low sensitivity is entered on the 8-bit scale and scaled by the script; the script's 8-bit constants are scaled to the clip's bit depth, with white mapped to the format maximum.
  • DeHalo_alpha also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

DeHalo_alpha is a port of the AviSynth function of the same name, taken over from havsfunc, which no longer contains it. The VapourSynth version rejects RGB, filters Gray clips directly and only the luma plane of YUV clips. FineDeHalo uses it as its dehalo step.

Sources