Avisynth MedianBlur

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

MedianBlur is a spatial median filter. Each pixel is replaced by the median of the pixels around it, which removes specks and impulse noise while keeping edges fairly sharp. Hybrid offers two plugins for it.

Filtering → Avisynth → Sharpen

MedianBlur controls in Hybrid
MedianBlur controls in Hybrid

What it does

For every pixel the filter looks at all pixels within a radius, sorts their values and takes the middle one. Isolated bright or dark pixels disappear, while straight edges stay almost as sharp as before. Larger radii remove bigger specks but also erase fine detail. The radius is set separately for the Y, U and V planes.

Typical uses:

  • Remove salt-and-pepper noise or dust specks from a clip.
  • Clean up chroma noise by filtering only U and V.

Settings

Control Parameter Range Hybrid default Meaning
Radius (Y/U/V) radiusy / radiusu / radiusv (MedianBlur2), radius (neo-smo) MedianBlur2: −256–127, neo-smo: 0–3 2 / 2 / 2 Radius of the median window for each plane. 0 copies the plane unchanged. With MedianBlur2, −1 to −255 fills the plane with the value −radius and anything below −255 fills it with 0.
Plugin – MedianBlur2, neo-smo MedianBlur2 Which plugin does the work. Changing it limits the radii to the range of the chosen plugin.

Example

Default settings (all radii 2) on a 10-bit YUV 4:2:0 source. Hybrid adds no conversion; the default radius equals the plugin's own default, so no argument is written:

MedianBlur()

How Hybrid calls it

  • MedianBlur2: MedianBlur(radiusy, radiusu, radiusv). Each radius is only written when it is not 2. Works on planar YUV and gray clips.
  • neo-smo: neo_smo_Median(radius=[y,u,v]). The radius is always written, because the plugin's own default is 1. For gray clips only one value is written. The radius is limited to 0–3. It works on gray and planar YUV clips up to float.
  • MedianBlur also offers the common options and can be added to the filter queue several times.

Background

  • MedianBlur2 is pinterf's AviSynth+ build of tritical's MedianBlur2. It handles 8–16 bit and float (float is quantised to 16 bit), copies an alpha plane, and uses the Y radius for all planes of planar RGB.
  • The plugin uses a constant-time algorithm, so the cost depends little on the radius, but there is a large jump in run time between radius 1 and 2.
  • The plugin also contains a temporal variant, MedianBlurTemporal, which Hybrid does not offer.
  • neo-smo is a separate plugin for AviSynth+ and offers a spatial median as one of its filters.

Sources