Blur

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (MMX)
(add link to avs+ documentation)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Func4Def|Blur(clip ''clip'', float ''amount'', bool ''MMX'')|Blur(clip, float ''amountH'', float ''amountV'', bool ''MMX'')|Sharpen(clip ''clip'', float ''amount'', bool ''MMX'')|Sharpen(clip, float ''amountH'', float ''amountV'', bool ''MMX'')}}
+
<div {{BlueBox2|40|0|3px solid purple}} >
 +
{{AvsPlusFullname}}<br>
 +
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/blur.html https://avisynthplus.readthedocs.io]
 +
</div>
  
This is a simple 3x3-kernel blurring [[Internal_filters|filter]]. The largest allowable argument for Blur is about 1.58, which corresponds to a ({{Frac|1|3}}, {{Frac|1|3}}, {{Frac|1|3}}) kernel. A value of 1.0 gets you a ({{Frac|1|4}}, {{Frac|1|2}}, {{Frac|1|4}}) kernel. If you want a large-radius Gaussian blur, I recommend chaining several copies of Blur(1.0) together. (Anybody remember Pascal's triangle?)
 
  
Negative arguments to Blur actually sharpen the image, and in fact Sharpen(n) is just an alias for Blur(-n). The smallest allowable argument to Blur is -1.0 and the largest to Sharpen is 1.0.
+
{{Func2Def
 +
|Blur(clip ''clip'', float ''amount'', bool ''MMX'')
 +
|Blur(clip, float ''amountH'', float ''amountV'', bool ''MMX'')
 +
}}
  
You can use 2 arguments to set independent Vertical and Horizontal amounts. Like this, you can use Blur(0,1) to filter only Vertically, for example to blend interlaced lines together. By default ''amountV''=''amountH''.
+
:A 3×3 [[Wikipedia:Kernel_(image_processing)|kernel]] blurring filter.  
  
A Known issue, with the MMX routines is the lack of full 8 bit precision in the calculations.{{Citation_needed}} This can lead to banding in the resultant image. Set
 
  
The ''MMX''=False option was originally to work around an MMX limitation, but this problem no longer exists. By default, ''MMX''=True.
+
{{Func2Def
 +
|Sharpen(clip ''clip'', float ''amount'', bool ''MMX'')
 +
|Sharpen(clip, float ''amountH'', float ''amountV'', bool ''MMX'')
 +
}}
  
'''Changes'''
+
:A 3×3 kernel sharpening filter; the inverse of '''Blur'''.
  
 +
 +
{{Par2|amount|float|(required)}}
 +
:The allowable range for '''Blur''' is from -1.0 to +1.58
 +
:The allowable range for '''Sharpen''' is from -1.58 to +1.0
 +
:Negative '''Blur''' actually ''sharpens'' the image; in fact Sharpen(''n'') is just an alias for Blur(''-n'').
 +
 +
 +
{{Par2|amountH|float|(required)}}
 +
{{Par2|amountV|float|(amountH)}}
 +
:You can use 2 arguments to set independent vertical and horizontal blurring or sharpening: for example,
 +
::<code>Blur(0,1)</code>
 +
:will blur vertical only, perhaps to blend interlaced lines together.
 +
 +
 +
{{Par2|MMX|bool|true}}
 +
:This option should always be ''true''.
 +
 +
 +
==== Notes ====
 +
If you need a larger radius Gaussian blur, try chaining several '''Blur'''s together:
 +
:<code>Blur(1.0).Blur(1.0).Blur(1.0)</code>
 +
 +
Chaining calls to '''Sharpen''' is not a good idea, as the image quickly deteriorates.
 +
 +
 +
==== Developer notes ====
 +
'''Blur''' uses the kernel [(1−1/2^amount)/2, 1/2^amount, (1−1/2^amount)/2]. The largest allowable argument for Blur is log2(3) (which is about 1.58), which corresponds to a (1/3,1/3,1/3) kernel. A value of 1.0 gets you a (1/4,1/2,1/4) kernel for example.
 +
Likewise Blur(1.0).Blur(1.0) is a convolution of the kernel (1/4,1/2,1/4) with itself, being a (1/4,1/2,1/4)*(1/4,1/2,1/4) = (1/16,4/16,6/16,4/16,1/16) kernel. It can be read of [https://en.wikipedia.org/wiki/Pascal's_triangle Pascal's triangle].
 +
 +
==== Changes ====
 
{| border=1 cellspacing=1 cellpadding=4
 
{| border=1 cellspacing=1 cellpadding=4
 +
| v2.58
 +
| MMX routines fixed (have full 8 bit precision now); mmx=true by default
 +
|-
 
| v2.57
 
| v2.57
 
| added MMX option
 
| added MMX option
Line 19: Line 59:
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 +
[[Category:Blurring]]

Latest revision as of 18:16, 17 September 2022

AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io


Blur(clip clip, float amount, bool MMX)
Blur(clip, float amountH, float amountV, bool MMX)

A 3×3 kernel blurring filter.


Sharpen(clip clip, float amount, bool MMX)
Sharpen(clip, float amountH, float amountV, bool MMX)

A 3×3 kernel sharpening filter; the inverse of Blur.


float  amount = (required)

The allowable range for Blur is from -1.0 to +1.58
The allowable range for Sharpen is from -1.58 to +1.0
Negative Blur actually sharpens the image; in fact Sharpen(n) is just an alias for Blur(-n).


float  amountH = (required)
float  amountV = (amountH)

You can use 2 arguments to set independent vertical and horizontal blurring or sharpening: for example,
Blur(0,1)
will blur vertical only, perhaps to blend interlaced lines together.


bool  MMX = true

This option should always be true.


[edit] Notes

If you need a larger radius Gaussian blur, try chaining several Blurs together:

Blur(1.0).Blur(1.0).Blur(1.0)

Chaining calls to Sharpen is not a good idea, as the image quickly deteriorates.


[edit] Developer notes

Blur uses the kernel [(1−1/2^amount)/2, 1/2^amount, (1−1/2^amount)/2]. The largest allowable argument for Blur is log2(3) (which is about 1.58), which corresponds to a (1/3,1/3,1/3) kernel. A value of 1.0 gets you a (1/4,1/2,1/4) kernel for example. Likewise Blur(1.0).Blur(1.0) is a convolution of the kernel (1/4,1/2,1/4) with itself, being a (1/4,1/2,1/4)*(1/4,1/2,1/4) = (1/16,4/16,6/16,4/16,1/16) kernel. It can be read of Pascal's triangle.

[edit] Changes

v2.58 MMX routines fixed (have full 8 bit precision now); mmx=true by default
v2.57 added MMX option
Personal tools