Vapoursynth MSharpen

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

MSharpen is a masked sharpener: it detects edges and sharpens only those, so noise and grain in flat areas are not amplified.

Filtering → Vapoursynth → Sharpen

MSharpen controls in Hybrid
MSharpen controls in Hybrid

What it does

A Sobel edge mask is built from the first plane and cut at Threshold. The picture is sharpened against a 3×3 blur and mixed with the original by Strength; the result is applied only where the mask marks an edge. Planes that are not processed are copied. MSharpen is the counterpart of MSmooth, which uses the same mask for smoothing.

Settings

Control Parameter Range / values Hybrid default Meaning
Threshold threshold 0 – 100 6 Edge sensitivity in percent of the maximum value; lower = more pixels count as edges and get sharpened.
Strength strength 0 – 100 39 Sharpening amount in percent (mix between original and sharpened pixel).
Planes planes all, chroma only, luma only all Planes that are sharpened. The edge mask always comes from the first plane; on RGB with all planes the three masks are combined.
Tools: Expr – akarin, cranexpr, std akarin (std without AVX2) Expression plugin.
Tools: RG – zsmooth, neo_smo zsmooth Plugin for the 3×3 blur.
Tools: EdgeMasks – edgemasks edgemasks Edge mask plugin.

Example

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

# sharpening using MSharpen
clip = msmoosh.MSharpen(clip, tools={'expr': 'akarin', 'rg': 'zsmooth', 'edgemasks': 'edgemasks'})

How Hybrid calls it

  • MSharpen works on integer clips; float clips are converted to integer first.
  • Threshold and Strength are only written when they differ from 6 / 39, the script's own defaults; Planes only when it is not all.
  • Both values are percentages; the script converts them to the bit depth, so no scaling is needed.
  • MSharpen also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

msmoosh

MSharpen and MSmooth were AviSynth plugins by Donald Graft; dubhater ported them to VapourSynth as msmoosh. That plugin is archived. Hybrid uses a script replacement with the same call signature; its results differ slightly from the original. Like the plugin, the script leaves float clips untouched, which is why Hybrid converts them first.

Sources