Vapoursynth Hysteria

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

Hysteria is Scintilla's line darkener (VapourSynth port by Overdrive80, fixes by BluBb_mADe). It darkens lines only inside an edge mask built with hysteresis.

Filtering → Vapoursynth → Line

Hysteria controls in Hybrid
Hysteria controls in Hybrid

What it does

Two edge masks are built: a clean one from a high threshold and a noisy one from a low threshold. Hysteresis grows the clean mask into the connected parts of the noisy one, so real lines are followed completely while isolated noise is left out. Inside the mask each luma pixel is darkened by its difference to the brighter neighbors, times Strength, limited by Luma cap and the min/max change. Only the luma is changed.

Settings

Control Parameter Range / values Hybrid default Meaning
Strength strength 0 – 10 1.0 Multiplier of the darkening amount.
Use mask usemask on/off on Off darkens every edge in the picture (thicker dark lines); keep Strength low then.
Threshold (low/high) lowthresh / highthresh 0 – 255 / 1 – 255 6 / 20 Thresholds of the noisy and of the clean edge mask.
Luma cap luma_cap 1 – 255 191 Pixels brighter than this are never darkened; 255 = no cap.
Change (min/max) minchg / maxchg 0 – 254 / 1 – 255 0 / 255 Smaller darkenings are dropped; larger ones are capped at max.
Show mask showmask on/off off Shows the edge mask instead of the result, for tuning the thresholds.
Tools: Expr – akarin, cranexpr, std akarin (std without AVX2) Expression evaluator.
Tools: Hysteresis – hysteresis, misc hysteresis Hysteresis implementation.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356):

# Using Hysteria for line darkening
clip = hysteria.Hysteria(clip, tools={'expr': 'akarin', 'hysteresis': 'hysteresis'})

How Hybrid calls it

  • Hysteria works on 8-, 10- and 16-bit YUV 4:2:0; other formats are converted first.
  • Values are only written when they differ from the defaults; Hybrid's defaults are the script's defaults.
  • Thresholds, Luma cap and the changes are on the 8-bit scale and are scaled to the bit depth by the script (255 = format maximum).
  • Hysteria also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

Luma only

Like the AviSynth original, Hysteria darkens only the luma; the chroma is passed through. With Show mask the output is the edge mask, lifted to a minimum gray of about 80 (8-bit scale), together with the source chroma.

Sources