GeneralConvolution
From Avisynth wiki
(Difference between revisions)
Raffriff42 (Talk | contribs) m (one more touch-up) |
m (→External Links: link is back up :^)) |
||
Line 108: | Line 108: | ||
== External Links == | == External Links == | ||
− | * [ | + | * [https://jeanbruenn.info/2011/03/13/avisynths-convolution-stuff-explained/ ''AviSynth’s GeneralConvolution explained''] |
* Some other examples can be found [http://web.archive.org/web/20100105183639/http://www.gamedev.net/reference/programming/features/imageproc/page2.asp here]. | * Some other examples can be found [http://web.archive.org/web/20100105183639/http://www.gamedev.net/reference/programming/features/imageproc/page2.asp here]. | ||
Revision as of 21:02, 6 October 2018
Performs a matrix convolution on an RGB32 clip.
Contents |
Syntax and Parameters
GeneralConvolution (clip clip, [ int bias, string matrix, float divisor, bool auto ] )
- clip clip =
- Source clip. Must be RGB32.
- int bias = 0
- Additive bias to adjust the total output intensity.
- string matrix = "0 0 0 0 1 0 0 0 0"
- A 3×3 or 5×5 matrix with 32 (9) or 52 (25) integer values.
- float divisor = 1.0
- Divides the output of the convolution before adding bias.
- bool auto = true
- Enables auto scaling. Auto scaling divides the output of the convolution by the sum of the elements of the matrix. The value of divisor is applied in addition to this auto scaling factor. If the sum of elements is zero, auto scaling is disabled.
The divisor is usually the sum of the elements of the matrix. But when the sum is zero, you can leave divisor=1 and use the bias setting to correct the pixel values. The bias could be useful if the pixel values are negative due to the convolution. After adding bias, the pixels are clipped to the range 0-255.
Around the borders the edge pixels are simply repeated to service the matrix.
Examples
- Blur:
GeneralConvolution(0, " 10 10 10 10 10 10 10 10 10 10 10 10 16 10 10 10 10 10 10 10 10 10 10 10 10 ", 256, false)
- Horizontal (Sobel) edge detection:
GeneralConvolution(0, " 1 2 1 0 0 0 -1 -2 -1 ", 8)
- Vertical (Sobel) Edge Detection:
GeneralConvolution(0, " 1 0 -1 2 0 -2 1 0 -1 ", 8)
- Displacement (simply move the position of the "1" for left, right, up, down)
GeneralConvolution(0, " 0 1 0 0 0 0 0 0 0 ")
- Displacement by half pixel up (auto scaling):
GeneralConvolution(0, " 0 1 0 0 1 0 0 0 0 ")
- Displacement by half pixel to the right (manual scaling):
GeneralConvolution(0, " 0 0 0 0 128 128 0 0 0 ", 256, false)
- Sharpness filter:
GeneralConvolution(0, " 0 -1 0 -1 5 -1 0 -1 0 ", 0, true)
- In this case, the new pixel values y(m,n) are given by
- y(m,n) = ( -1*x(m-1,n) - 1*x(m,n-1) + 5*x(m,n) - 1*x(m,n+1) - 1*x(m+1,n) )/1.0 + 0
- Slight blur filter with black level clipping and 25% brightening:
GeneralConvolution(-16, " 0 12 0 12 256 12 0 12 0 ", 0.75 ,true)
- In this case, the new pixel values y(m,n) are given by
- y(m,n) = ( 12*x(m-1,n) + 12*x(m,n-1) + 256*x(m,n) + 12*x(m,n+1) + 12*x(m+1,n) )/(12+12+256+12+12)/0.75 - 16
- Emboss filter (3D relief effect)
GeneralConvolution(128, " -1 0 0 0 0 0 0 0 1")
External Links
- AviSynth’s GeneralConvolution explained
- Some other examples can be found here.
Changelog
v2.55 | Added divisor, auto. |
v2 | Initial Release |