From Avisynth wiki
Revision as of 20:02, 25 June 2020 by Reel.Deal (Talk | contribs)
Jump to: navigation, search
Author ajk
Version v0.6-RGB64
Category Averaging
License Public domain. Credit would be nice, but do with this what you will.
Discussion Doom9 Thread, VideoHelp Thread



Median.dll is a filter plugin for AviSynth which generates a pixel-by-pixel median of several clips. This is particularly useful for filtering out noise and glitches from multiple VHS/SVHS/8mm/Hi8 tape captures, but can be used for other purposes also.


Syntax and Parameters


Median() is the namesake function for this filter package. It takes a number of clips and outputs a frame which is the median of the input. Because for noise filtering applications having all the input clips exactly in sync is important, it also includes functionality to line up slight mismatches that can be present due to framedrops during capture.

Median (clip, clip, clip, ..., bool "chroma", int "sync", int "samples", bool "debug")

clip   =
Input clips between 3 and 25 are accepted. Odd number of clips is required.

bool  chroma = true
Chroma is processed by default, but this can be turned off in which case the chroma from the first clip is used. In the case of RGB input, all colour planes are always processed. With RGB32 the chroma parameter can be used to turn off alpha channel processing.

int  sync = 0
If the clips are not exactly in sync, you can use this parameter to automatically line them up. The plugin will search up to this number of preceding and following frames to find the best match.

int  samples = 4096
Number of pixels to compare when determining similarity of frames for synchronization. The default seems to be fine most of the time but this parameter allows you to tweak the process.

bool  debug = false
Turns on debug output.


There is also another, more flexible filter included, MedianBlend(). This function can be adjusted to for example return a clip derived from the minimum or maximum pixel values, or to discard some low (default: 1) and high (default: 1) values and blend the others together. With the paramteters set to not discard anything, the result is in fact the average of the clips. The other parameters work the same way as for Median().

Median (clip, clip, clip, ..., int "low", int "high", bool "chroma", int "sync", int "samples", bool "debug")

clip   =
Input clips between 3 and 25 are accepted.

int  low = 1
Number of low (dark) samples to discard.

int  high = 1
Number of high (light) samples to discard.

bool  chroma = true

int  sync = 0

int  samples = 4096

bool  debug = false


You can also use the filter temporally on a single source clip. You can use a radius of up to 12 and the filter will take that many preceding and following frames into account when calculating the median. The other parameters work the same way as for Median().

Median (clip, int "radius", bool "chroma", bool "debug")

clip   =
Input clip.

int  radius = 1
Number of preceding and following frame to consider when calculating the median.

bool  chroma = true

bool  debug = false


Median of three clips, chroma is not processed:

clip1 = AVISource("capture1.avi")
clip2 = AVISource("capture2.avi")
clip3 = AVISource("capture3.avi")
Median(clip1,clip2,clip3, chroma=false)

Median of three clips, match frames up to 10 frames forward and back, print debug data on the image:

Median(clip1,clip2,clip3, sync=10, debug=true)

Discard no values, output is an average function

 MedianBlend(clip1,clip2,clip3, low=0, high=0)

Discard highest values, output is a minimum function

MedianBlend(clip1,clip2,clip3, low=0, high=2)

Discard lowest values, output is a maximum function

MedianBlend(clip1,clip2,clip3, low=2, high=0)

Discard highest and lowest value and average the two remaining ones

MedianBlend(clip1,clip2,clip3,clip4, low=1, high=1)

Median of five frames: current, two preceding, and two following:

TemporalMedian(clip, radius=2)


Version      Date            Changes
v0.6-RGB64 2019/02/01 - Changes by TomArrow[1] - Support RGB64 (but not the fast processing mode that's supported in the 8-bit color spaces) - Implement the new AviSynth+ API (V6) - Have both 32 bit and 64 bit platforms set up for VS 2017 v0.6 2016/01/16 - Added automatic clip synchronisation. v0.5 2014/03/15 - Fixed bug with chroma=false. Added TemporalMedian() functionality. v0.4 2014/02/14 - Added MedianBlend() functionality. v0.3 2014/02/13 - Fixed output frame buffer issue. v0.2 2014/02/13 - Added support for other colour spaces (planar and RBG24/32). v0.1 2014/02/12 - Initial release. YUY2 support only.

Archived Downloads

Version Download Mirror

For older versions take a look at ajk's repository (archived).

External Links

Back to External Filters

Personal tools