MedianBlur2

From Avisynth wiki
Jump to: navigation, search
Abstract
Author tp7
Version v0.94
Download MedianBlur2-x86.zip

MedianBlur2-x64.zip

Category Blurring
License MIT but binaries are GPLv2
Discussion Doom9 Thread


Contents

Description

MedianBlur2 is an implementation of constant time median filter for AviSynth; it includes 2 functions:

  • MedianBlur - a simple median filter similar to the old MedianBlur (function name is still MedianBlur).
  • MedianBlurTemporal - partially implements the old MedianBlurT function but doesn't have MVTools2-related parameters (hence the function name change). If you don't use the mo-comp part of it, you should be able to just change the name used without any other changes.
    Please do note that for temporal-only processing this filter is extremely inefficient (just like the original).


Performance

Unlike the old MedianBlur, this implementation has constant runtime complexity, meaning that theoretical performance is the same for any radius. Implementation is based on this paper, but includes some additional optimizations.

  1. When SSE2 is available and radius is 1 or 2, special routines are used. They're a lot faster than the generic one for these radii.
  2. For 2 < radius < 8, generic approach with 8-bit bin size is used. Using 8-bit bins makes histogram addition/subtraction faster with SSE2.
  3. For large radii, 16-bit bins are used, as described in the paper.

In other words, you can expect huge performance drop when going from 1 to 2, not so huge but still large from 2 to 3 and a noticeable slowdown from 7 to 8. Between them the fps should be constant and it actually might get a bit faster with larger radius. Performance with radius > 2 also depends on the actual frame content. Processing ColorBars() is a lot faster than AddGrainC(10000). It is quite possible that you'll get worse performance for radius = 3 with this plugin compared to the original MedianBlur. All other radii should be (a lot) faster.

Requirements


*** vcredist_x86.exe is required for MedianBlur2-x86
*** vcredist_x64.exe is required for MedianBlur2-x64


Syntax and Parameters

MedianBlur

Spatial-only version.

MedianBlur (clip, int "radiusy", int "radiusu", int "radiusv")


clip   =
Input clip must be planar.


int  radiusy = 2
int  radiusu = 2
int  radiusv = 2
Spatial radius; YUV planes are independently processed.
  • If set to 0 the corresponding plane is copied from the input clip unaltered.
  • If set between -1 and -255 the corresponding plane will be set to -radius.
  • If set to any value less than -255 the corresponding plane will be set to zero.
  • 2 is the default for all planes; maximum value is limited to 127.



MedianBlurTemporal

Spatio-temporal version.


MedianBlurTemporal (clip, int "radiusy", int "radiusu", int "radiusv", int "temporalradius")


clip   =
Input clip must be planar.


int  radiusy = 2
int  radiusu = 2
int  radiusv = 2
Spatial radius; YUV planes are independently processed.
  • Setting it to 0 will just disable spatial filtering.
  • Setting it to -1 will copy the plane from the input clip.
  • All other values will set the plane to absolute value of radius. Yes, there is no way to set the plane to -1.
  • If set to any value less than -255 the corresponding plane will be set to zero.
  • 2 is the default for all planes; maximum value is limited to 127.


int  temporalradius = 1
Value must be greater than 0; the higher the value the slower it gets.


Examples

  • MedianBlur with default settings:
AviSource("blah.avi")
MedianBlurTemporal(radiusy=2, radiusu=2, radiusv=2)
  • MedianBlurTemporal with default settings:
MedianBlurTemporal(radiusy=2, radiusu=2, radiusv=2, temporalradius=1)  
MedianBlurTemporal(radiusy=0, radiusu=0, radiusv=0, temporalradius=1)  


Changelog

Version      Date            Changes
v0.94 02/10/2014 - MedianBlurTemporal now produces more correct result around the clip borders (first and last frames). - Both functions allow radii less than -255, corresponding plane is set to zero. For compatibility with YAHR and possible other functions.
v0.93 12/27/2013 - This fixes a huge memory leak in MedianBlurTemp which made it unusable in complex scripts. The function is also renamed to MedianBlurTemporal, which is probably the final name.
v0.92 12/09/2013 - Spatiotemporal median filter called MedianBlurTemp added. Function name is subject to change.
v0.91 12/08/2013 - Plane processors are now independent from each other. It means when you write something like MedianBlur(5,1,1), both chroma planes will now be processed by the optimized routine, rather than the general one as before.
v0.9 12/08/2013 - Initial release.


Archived Downloads

Take a look at the GitHub releases page.

External Links




Back to External Filters

Personal tools