Avisynth RemoveGrain

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

RemoveGrain is a spatial 3×3 filter with many modes: clipping, blurring, median filters, bob interpolation, halo removal and light sharpening. It is a light denoiser and a common building block of other scripts.

Filtering → Avisynth → DeGrain

RemoveGrain controls in Hybrid
RemoveGrain controls in Hybrid

What it does

Every pixel is processed using only its eight neighbours in the same frame; nothing from other frames is used. The Mode selects the operation:

  • 1–4: clip the pixel to the range of its neighbours (1 is the mildest, 4 the strongest).
  • 5–10, 17, 18, 21, 22: line-sensitive clipping that keeps thin lines.
  • 11, 12, 19, 20: blurs of different strength.
  • 13–16: interpolate missing lines of one field (bob).
  • 23, 24: halo removal.
  • 25–28: sharpening and median blurs.
  • 0 copies the plane unchanged. For chroma, -1 leaves the plane untouched.

Mode 2 is the default and a mild general denoiser. Stronger modes remove more grain but also soften detail.

Requirements

Windows, CPU only. neo-smo.dll and RgTools.dll are shipped with Hybrid.

Settings

Control Parameter Range Hybrid default Meaning
Mode mode 0–28 2 Filter mode for luma. Chroma follows it unless overridden below.
ModeU modeU -1–28 2 (off) Own mode for the U plane. Only active when the check box is ticked; otherwise U uses Mode.
ModeV modeV -1–28 2 (off) Own mode for the V plane. Only active when the check box is ticked; otherwise V uses the U mode.

Example

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

last.neo_smo_RemoveGrain(mode=[2,2,2])

How Hybrid calls it

  • When all three planes use modes up to 24, Hybrid loads neo-smo.dll and calls neo_smo_RemoveGrain with one mode for gray clips or a Y, U, V list for color clips.
  • When any plane uses a mode from 25 to 28, Hybrid loads RgTools.dll and calls Removegrain instead. Then Mode is always written, and ModeU and ModeV are written whenever their check box is ticked (RgTools would otherwise use its own default of 1 for the luma mode).
  • Works on gray, planar YUV and planar RGB, 8–16 bit and float. YV411, YUY2 and packed RGB are not supported.
  • The filter is not interlace-aware; Hybrid separates the fields of interlaced input first.
  • The 1-pixel border is filtered by neo-smo and copied unchanged by RgTools. The interior is the same up to rounding.
  • RemoveGrain also offers the common options and can be added to the filter queue several times.

Background

RemoveGrain was written by Kassandro. RgTools by pinterf is the maintained version and adds high bit depth and float support, so it supplies modes 25–28. The neo-smo plugin contains a port of the earlier modes.

See also: Vapoursynth RemoveGrain. The VapourSynth version has one mode for all planes and a choice of tool.

Sources

  • RgTools (pinterf) README
  • Hybrid's tooltips
  • The AviSynth+ documentation does not cover RemoveGrain.