Avisynth BucketMedian

From wiki.selur.net
Revision as of 19:49, 21 November 2026 by Selur (talk | contribs) (Avisynth filter documentation (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

BucketMedian is a spatial median filter by chikuzen that uses bucket (counting) sort. It removes single-pixel specks from the luma plane.

Filtering → Avisynth → Sharpen

BucketMedian controls in Hybrid
BucketMedian controls in Hybrid

What it does

Each luma pixel is replaced by the median of its (2r+1) × (2r+1) neighbourhood, but only if the median differs from the pixel by less than the Threshold and the pixel value lies inside the Min/Max range. Otherwise the pixel stays as it is. Chroma passes through unchanged. Large radii are slow.

Typical uses:

  • Remove isolated bright or dark specks.
  • Restrict the filter to a value range, for example to leave very dark or very bright areas untouched.

Settings

Control Parameter Range Hybrid default Meaning
Strength radius 1–255 1 Radius of the median window; the window is (2r+1) × (2r+1) pixels.
Threshold thresh 1–255 1 median − pixel| is smaller than this value.
Min/Max min / max 0–254 / 1–255 0 / 255 Pixels with a value below Min or above Max are not processed.

Example

Default settings on a 10-bit YUV 4:2:0 source. All values equal the plugin defaults, so no argument is written:

BucketMedian()

How Hybrid calls it

  • Loads BucketMedian.dll.
  • The plugin works on planar YUV and gray clips.
  • Only arguments that differ from the defaults are written.
  • BucketMedian also offers the common options and can be added to the filter queue several times.

Background

  • BucketMedian 0.3.0 (2012) by chikuzen was written for 32-bit AviSynth 2.5; Hybrid ships a 64-bit build of the same code for AviSynth+.
  • Border handling was removed from the plugin in 0.3.0 and moved into a separate script, BMBorderProc.avsi, which Hybrid does not use.
  • The project documentation itself warns that the filter is slow.

Sources