DctFilter
Abstract | |
---|---|
Author | Tom Barry |
Version | v0.0.1.4 |
Download | DctFilter.zip |
Category | |
License | GPLv2 |
Discussion |
Contents |
Description
An experimental filter that, for each 8x8 block, will do a Discrete Cosine Transform (DCT), scale down the selected frequency values, and then reverse the process with an Inverse Discrete Cosine Transform (IDCT).
Requirements
- AviSynth 2.5.8 or greater
- Supported color formats: YUY2, YV12
- Width and height need to be a multiple of 16 (mod16)
Known Issues
- Stripe bug - both variants are buggy at calculating DC, additional information here and here.
Syntax and Parameters
DctFilter
There are 8 positional floating point parameters, all of which must be specified as in the range (0.0 <= x <= 1.0). These correspond to scaling factors for the 8 rows and columns of the 8x8 DCT blocks.
The leftmost parameter corresponds to the top row, left column. This would be the DC component of the transform and should always be left as 1.0.
- DctFilter (clip, float, float, float, float, float, float, float, float)
In the following example the highest frequency components in each row and column will be zeroed while the 2nd highest would be cut in half.
AviSource("Blah.avi") DctFilter(1,1,1,1,1,1,.5,0)
The row & column parms are multiplied together to get the scale factor for each of the 64 values in a block. So if the top left value was V[0,0] then in the example above the we would scale row 6, col 6 (V[6,6]) by .5 * .5 = .25.
Note that while they look like floating point parms above they really now only
have 3 bit accuracy so the only actual values used are 0, 1/8, 1/4, 3/8 ... 1.0. But you can specify any value and it will be rounded to the nearest one.
DctFilterD
DctFilterD works similar to DctFilter but will zero out DiagCt number of the lower right diagonals of the DCT, leaving other values unchanged.
In an 8x8 DCT result matrix there are 15 possible diagonals (visualize a chess board), so if you specify DctFilterD(4)
then the 4 diagonals in the lower right corner of the DCT result will be set to 0.
I haven't tested this much but, like my results with custom quant tables, it appears if you set DiagCt very large you will start to get edge noise, something like ringing.[1]
- DctFilterD (clip, int)
- clip =
- Input clip.
- clip =
- int =
- "DiagCt" must be an integer from 1-14 saying how many of these diagonals must be zeroed, starting from the lower right hand corner.
- int =
DctAddConstant
Not much is known about this filter...
- DctAddConstant (clip, float, float, float, float)
Examples
Remove high frequency components:[2]
AviSource("blah.avi") DctFilter(1,1,1,.8,.4,0,0,0)
DctFilterD can be used as a fast way to average 8x8 blocks:[3]
AviSource("blah.avi") DCTFilterD(14)
#DctFilter(1,0,0,0,0,0,0,0) - keeps the topmost line and leftmost row.[4]
Very easy way to get the normalized SAD over 8x8 blocks:[5]
mt_lutxy(clip1,clip2,"x y - abs").DctFilterD(14)
Measure luma variance within block (e.g. 8x8) of pixels?[6]
The easiest somewhat correct "amount of variation for each block" you can get is using STD for each pixel and applying DctFilter to it (adjust the radius of STD calculation area for possibly better results).
mt_luts(last, "std", mt_square(1), "y").mt_lut("x 15 *") DctFilter(1,0,0,0,0,0,0,0).Greyscale()
A reasonably close approximation with a lot better performance is an edge mask:
mt_edge("min/max", 0, 255, 0, 255).mt_lut("x 5 *") DctFilter(1,0,0,0,0,0,0,0).Greyscale()
Changelog
Version Date Developer Changes
v0.0.1.4 2003/02/21 Tom Barry - Add DctFilterD, diagonal support v0.0.1.3 2003/01/30 Tom Barry - Avisynth 2.5 beta, plugininit2, vs6 v0.0.1.2 2002/11/2? SansGrip - YUY2 support v ? 2002/11/25 Tom Barry - Initial test release for Avisynth 2.5 alpha only
Archived Downloads
Version | Download | Mirror | Mirror 2 |
---|---|---|---|
v0.0.1.4 | DctFilter.zip | dctfilter_dll_20030221.zip |
External Links
- AquilineStudios - Additional information on usage.
- Doom9Forum - Another advanced usage example.
- Doom9 Forum - Possible update to DctFilter.
Back to External Filters ←