Vapoursynth LSFmod

From wiki.selur.net
Revision as of 09:50, 16 November 2026 by Selur (talk | contribs) (Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

LSFmod (LimitedSharpenFaster mod) is a strong edge and detail sharpener that keeps halos, aliasing and small "confetti" artifacts in check by limiting the result to the local minimum and maximum.

Filtering → Vapoursynth → Sharpen

LSFmod controls in Hybrid
LSFmod controls in Hybrid

What it does

The picture is optionally pre-blurred, then sharpened with range, non-linear or contrast adaptive (CAS) sharpening. The result is limited to the local minimum and maximum plus an allowed over- and undershoot, optionally softened, and can be applied only on or off edges. soothe stabilizes the sharpening over time, secure guards against banding and a waxy look. On YUV only luma is sharpened; RGB is not supported.

Settings

Control Parameter Range / values Hybrid default Meaning
Defaults defaults old, slow, fast fast Preset; Apply loads its values into the fields.
Strength strength 0 – 8192 80 Sharpening strength.
Sharpening Mode Smode Range sharpening, Nonlinear sharpening, Contrast Adaptive Sharpening Contrast Adaptive Sharpening Sharpening method.
Method Smethod 3x3 Kernel, Min/Max, Min/Max + 3x3 Kernel Min/Max How the blurred reference is built; only for range and non-linear mode.
Kernel kernel 11, 20, 12, 19 11 Blur kernel when Method uses a kernel; 11 and 12 are the same convolution here, 19 is a ring of 8, 20 a box.
PreBlur preblur none, MinBlur(0), MinBlur(1), MinBlur(2), DFTTest MinBlur(0) Blur before sharpening to avoid sharpening noise.
secure secure on/off on Protects against banding and a waxy look; also applies in CAS mode.
Zero point Szrp 1 – 255 16 Non-linear mode: zero point of the curve (8-bit units).
Power Spwr 1 – 16 4 Non-linear mode: exponent of the curve.
Damp lo / hi SdmpLo / SdmpHi 0 – 255 4 / 48 Non-linear mode: damping of small and large differences (8-bit units).
Limiting mode Lmode Repair(18..1), No Limit, over/undershoot, edges only, zero on edges, edges + overshoot2 on not-edges No Limit How the sharpened result is limited.
Overshoot / Undershoot overshoot / undershoot 0 – 81 0 / 0 Allowed overshoot and undershoot (8-bit units).
Overshoot2 / Undershoot2 overshoot2 / undershoot2 0 – 162 twice the first values Values for the non-edge areas; only for Limiting mode 4.
Soft soft -2 – 100 0 Softening of the sharpening; -1 old auto, -2 new auto.
Soothe / Keep soothe / keep on/off, 0 – 100 off, 20 Temporal stabilization of the sharpening; Keep sets how much is kept.
Edge mode edgemode Show edgemask, Sharpening all, only edges, only not-edges Sharpening all Where sharpening is applied; Show edgemask outputs the mask.
HQ edgemaskHQ on/off off Better edge mask; used by Edge mode, Show edgemask and Limiting modes 2 – 4.
Supersampling X / Y ss_x / ss_y 1 – 4 preset value (1.0 / 1.0 with fast and Contrast Adaptive Sharpening) Supersampling factors against aliasing on edges. They follow the preset and the sharpening mode like the other preset-driven fields: old 1.5 with Range sharpening, else 1.25; slow 1.0 with Contrast Adaptive Sharpening, else 1.5; fast 1.0 with Contrast Adaptive Sharpening, else 1.25. Y follows X by default.
Tools: Expr – akarin, cranexpr, std akarin (std without AVX2) Expression plugin.
Tools: DFTTest – neo_fft, dfttest2cpu, dfttest2, vszipcu, vsfeel – DFTTest implementation for PreBlur DFTTest; GPU variants need CUDA or Vulkan.
Tools: RG – zsmooth, neo_smo zsmooth Repair plugin for the Repair limiting modes.
Tools: Median – zsmooth zsmooth Median for MinBlur(2).
Tools: SCD – scd, misc, std, mv scd Scene change detection for soothe; with mv the motion vector thresholds are used.

Example

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

# sharpening using LimitedSharpenFaster(Mod)
clip = sharpen.LSFmod(clip, defaults="fast", tools={'expr': 'akarin', 'dfttest': 'neo_fft', 'rg': 'zsmooth', 'median': 'zsmooth', 'scd': 'scd'})

How Hybrid calls it

  • LSFmod works on gray and YUV clips of any bit depth; other formats are converted first.
  • The preset is always written; every other value only when it differs from what the preset would set, so the script runs exactly what the controls show. Method and Kernel are left out where they do not matter, Overshoot2/Undershoot2 are only written for Limiting mode 4.
  • With PreBlur DFTTest and a GPU DFTTest tool the GPU path is switched on.
  • Over-/undershoot and the damp values are given on the 8-bit scale; the script scales them to the bit depth.
  • ss_x is written when it differs from the preset value, ss_y when it differs from ss_x. The output size is not offered; the output keeps the input size.
  • LSFmod also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

Origin

LSFmod is LaTo's AviSynth modification of Didée's LimitedSharpenFaster; the VapourSynth version was part of havsfunc. The presets derive several values from Strength (for example the default overshoot and damping). The CAS mode uses the same plugin as CAS.

Sources