MedianBlur2

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(v1.0 minor touchup)
m (add Deep_color_tools category)
 
Line 1: Line 1:
{{FilterCat5|External_filters|Plugins|Plugins_x64|Adjustment_filters|Blurring}}
+
{{FilterCat6|External_filters|Plugins|Plugins_x64|Adjustment_filters|Blurring|Deep_color_tools}}
 
{{Filter3
 
{{Filter3
 
| {{Author/tp7}}, {{Author/pinterf}}
 
| {{Author/tp7}}, {{Author/pinterf}}
Line 34: Line 34:
 
* [x64]: [[AviSynth+]]
 
* [x64]: [[AviSynth+]]
 
* Supported color formats: [[Y8]], [[YV12]], [[YV16]], [[YV24]], [[YV411]]
 
* Supported color formats: [[Y8]], [[YV12]], [[YV16]], [[YV24]], [[YV411]]
** AviSynth+: All planar formats (8/10/12/14/16/32bit, Y/YUV/RGB with or without alpha) are supported.  
+
** AviSynth+: All [[planar]] formats (8/10/12/14/16/32-bit, Y, YUV(A), and RGB(A) with or without alpha) are supported.  
 
<br>
 
<br>
 
* [https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads Microsoft Visual C++ 2019 Redistributable Package (x86 / x64)]
 
* [https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads Microsoft Visual C++ 2019 Redistributable Package (x86 / x64)]

Latest revision as of 22:12, 25 June 2020

Abstract
Author tp7, pinterf
Version v1.0
Download MedianBlur2_v1.0.7z
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.

High bit depth considerations:

At larger bit depths performance drops because internal histogram tables contain statistical data for 10, 12, 14 and 16 bits precision. Also: higher bit depths need more memory. Unfortunately 32 bit float is faked: float data have to be quantized before processing and is using 16 bit histogram so resulting pixel values are quantized to 16 bits as well. Radii 1 and 2 are special case only for 8 bits as of v1.0.

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.
For RGB clips radiusy value is used for all planes.
  • 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. Works only for 8 bits
  • 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.


If alpha plane is available it will be simply copied.
Planar RGB uses the value of radiusy for all its channels. radius u and radius v are ignored.



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.
For RGB clips radiusy value is used for all planes.
  • 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. Works only for 8 bit clips.
  • 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.


If alpha plane is available it will be simply copied.
Planar RGB uses the value of radiusy for all its channels. radius u and radius v are ignored.


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
v1.0 04/02/2020 (pinterf) - add high bitdepth support - add planar RGB support - add version resource to DLL - move to Visual Studio 2019, ClangCL, v141_xp and v142 configurations - project hosted at https://github.com/pinterf/MedianBlur2
v0.94 02/10/2014 (tp7) - 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. - Compiled with MSVC++12, requires 2012 Redistributable Package (x86 / x64)
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.


External Links




Back to External Filters

Personal tools