Vapoursynth DeGrainMedian

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

DeGrainMedian is a spatio-temporal median denoiser for light grain. It keeps detail well because no pixel may move more than a set limit from its original value.

Filtering → Vapoursynth → DeGrain

DeGrainMedian controls in Hybrid
DeGrainMedian controls in Hybrid

What it does

For every pixel the 3×3 neighborhoods in the previous, current and next frame are compared, and a median-like value is chosen depending on the Mode. The change is limited to Limit, so edges and fine detail survive.

Settings

Control Parameter Range Hybrid default Meaning
Limit (Y/U/V) limit 0 – 255 each 4 / 4 / 4 Maximum change of a pixel, on the 8-bit scale; 0 leaves the plane unchanged.
Mode (Y/U/V) mode 0 – 5 each 1 / 1 / 1 0 is the strongest, 5 the weakest mode (0 is a spatio-temporal RemoveGrain mode 9, 1 a stronger mode 8, 2 mode 8, 3–5 modes 7, 6 and 5).
No row norow on/off off Leaves the left and right neighbors in the current frame out.

Example

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

# applying degrain using DegrainMedian
clip = core.zsmooth.DegrainMedian(clip, interlaced=False, scalep=True)

How Hybrid calls it

  • DeGrainMedian works on 8–16-bit integer YUV.
  • Limit and Mode are written as one value when all three planes are equal, otherwise per plane; both only when they differ from the defaults.
  • The limits are entered on the 8-bit scale; Hybrid lets the plugin scale them to the clip's bit depth (scalep).
  • The filter is interlace-aware: Hybrid passes whether the clip is interlaced instead of separating the fields.
  • DeGrainMedian also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

zsmooth (DegrainMedian)

zsmooth by adworacz is a collection of fast smoothing filters for VapourSynth; its DegrainMedian is a port of Fizick's AviSynth DeGrainMedian. It accepts 8–16-bit integer and 16/32-bit float RGB, YUV and gray clips. With interlaced the top and bottom rows of the 3×3 neighborhood come from the same field; scalep scales the thresholds from the 8-bit range.

AviSynth

The original DeGrainMedian plugin by Fizick has the same limit and mode parameters.

Sources