#
vcfreq

Author V. C. Mohan
Date Jun 2015
All my plugins are available for free download from "here".

vcfreq plugin for vapoursynth version r24, is free and the author does not give any guarentee for its operation. It may be downloaded and used at the users risk.

vcfreq has 4 functions: F2Quiver, F1Quiver, Blur and Sharp. This plugin is available in 32 and 64 bit versions is ported with suitable modifications from the original avisynth plugins FFTQuiver and FQSharp , The 4 functions in this plugin transforms data into frequency domain utilising libfftw3f-3.dll of 32bit or 64bit depending upon which version of vcfreq dll is being used( or, FFTW3 dll, or fftw.dll) being available in path. A large variety of filters are available for use ( a quiver full of arrows)and hence the name. Some type of noises are best attenuated in frequency domain. F1Quiver uses a one dimensional transform, while F2Quiver, Blur and Sharp operates using 2d transforms.

Constant format YUV or Grey input only. Blur and Sharp accepts RGB input also. In case of RGB all 3 planes are processed while in YUV only Y is processed. RGB is three times slower. Converting to YUV prior to processing will run faster.
Note that the sharper the filter more the ringing. Any sharp edge in image has all frequencies and filtering some noise frequencies degrades the image also.
------------------------------------------------------------------------------------------------

## F1Quiver

This function operates on image row by row. Certain types of regular repetitive noise such as power line frequency hum interference can be attenuated. The test mode displays 1D frequency spectrum averaged over a number of rows, along with a ruler to find exact frequency and also displays filter which is designed. The ruler marks 100s, 50s and 10s or 100s, 20s depending on legibility consideration. Butterworth low pass, high pass, band pass, band reject filters of appropriate frequencies can be specified.Up to 16 filters can be cascaded. Each filter requires 4 values. Alternatively a custom designed filter can be used. In which case two values per point upto 32 points of (freq, %response) are required to be specified. At least one filter must be specified. Homomorphic filtering option is available. Gamma enables viewing small valued responses in the spectral display. Most images have considerable DC component and sum of this is at Origin. Compared to other frequencies this is very large and can not be normally seen in pixel value range. The bottom display of freq spectrum depicts this. The top half is display using gamma factor.

Constant format YUV or Grey input only.

More detailed description can be seen at FFTQiver link provided above.

the script call for F1Quiver is

## vcfreq.F1Quiver(clip, int filter[ filter1[..] ][, int morph = 0][,int custom = 0][,int test = 0][,int strow = 0] [, int nrows = height / 2][,float gamma = 0.05] )

Each Butterworth filter spec is {type, freq1, freq2, degree} where
type = 1 for low pass, 2 for high pass, 3 for band pass, 4 for band reject
freq1: Frequency of low or high pass or lower freq of band pass or reject. 1 to ruler end value
freq2: Higher freq in case of band pass or reject. Other cases will not use this value, but must be given. Must be more or equal to freq1
degree : degree of sharpness of filter. 1 to 12
If custom is set, then filter specs are[freq, %response]. Freq should monotonously increase
starting from strow nrows freq spectra are averaged for display.
morph: if set does homomorphic transform. Need to filter accordingly. (ref literature). Incidentally this option for test shows up low values better.
------------------------------------------------------------------------------------------------

## F2Quiver

This function does a 2D transform of each frame, applies designed filter and inverse transforms for output. Upto 12 Butterworth or Gauss 2D filters can be specified. These are cascaded and applied.To enable determining frequencies and symmetries test facility is provided. In test mode the frequency spectrum and designed filters are displayed. In the 2d frequency spectrum, one may notice symmetries of image elements and noise. Homomorphic filtering is an option. The filter radius frad specifiess filter radius in image domain. Required padding to eliminate wrap aound effect is done

Constant format YUV or Grey input only.
The call for this function is:-

## vcfreq.F2Quiver(clip[ , int frad = 32][,int test = 0][, int morph = 0][, float gamma = 0.05], int fspec = [spec1][,......] ] )

frad can vary from 16 to 1/4 of smaller frame dimension in steps of 4. Note that large frad increases time of processing.
gamma from 0.0001 to 5.0
test: set to 1 for test mode
morph : set to one for homomorphic process.This mode during test improves display. For regular processing refer literature for need and filtering.
fspec = [ array of 1 to 12 integer sets, each set has 5 values(symmetry, type, freq1, freq2, degree). At least one set must be specified.
symmetry: 1. circular, 2 Horizontal, 3.vertical, 4. Fan line through origin, 5. points in the spectrum. Note that in spectrum opposite quadrants are similar so defining in one automatically defines in the opposite quadrant.Depending on similarity, the parameter definition changes.
Type : 1 low cut (or high pass) 2. Hicut (or low freq pass) 3.band pass 4. band stop 5. notch. For point symmetry only notch is designed.
freq1: freq of cut or notch, or low freq of pass or stop, or angle1 in degrees (0 to 89, 91 to 179)of fan. X freq coordinate of point. Freq values of 0 to 255
freq2: higher freq of band or angle 2 of fan spread. Angle 2 should be more than angle1.(angle2 and angle1 both must be either between 1 to 89 degrees or 91 to 179 degree range.) Some value must be specified even if not applicable.Y freq coordinate of point. freq2 value of 2 to 255, Y freq coord of -255 to 255
degree: degree of sharpness of filter. 1 to 24. If set to 1 , gaussian, otherwise butterworth filters are designed
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
example test code for F1Quiver.Top left freq spectrum with gamma scaling, filter used. Left lower half unscaled specrtrum. Right top half filtered output. Right lower half unfiltered input.
core.vcfreq.F1Quiver(ret,custom = 1,morph = 0,strow=50,nrows=200, test = 1,filter = [50,100,80,1,100,100], gamma = 0.091)
Example for F2Quiver. Left input, middle filtered output (test = 0), right freq spectrum and right extreme filters used(test = 1 mode).
core.vcfreq.F2Quiver(ret,test = 0,fspec=[3,4,70,80,12,5,4,75,40,12, 5,4,75,-220,12,3,4,70,80,12],gamma=0.05)
----------------------------------------------------------------- --------------------------

## Blur

the script call is

## vcfreq.Blur(clip [, int line = 1][,int x = 2][,int y = 2])

clip: input clip must have constant dimensions and of RGB or YUV or Grey format only. All 3 planes of RGB, only y of YUV formats are processed. Converting input to YUV format is prferable.
line: If set to 1 linear type (motion blur). If 0 circular type such as camera out of focus.
x: x coord of line end. Must be in range of 0 to 1/8 of frame width. For circular blur this is radius of circle. Minimum 1, max 1/8 of width. Value is symmetrical to origin.;
y : y coord of line end. Valid values are from - 1/8 to 1/8 of frame height. Value is symmetrical to origin For circular blur ignored;
------------------------------------------------------------------------------------------------

## Sharp

The call for this function is:-

## vcfreq.Sharp(clip[ , int line = 1][, float wn = 0.05][,int x = 2][, int y = 2][, int fr = 10][, float scale = 0.45 ] )

clip: input clip must have constant dimensions and of RGB or YUV or Grey format only. All 3 planes of RGB, only y of YUV formats are processed. Converting input to YUV format is prferable.
line: If set to 1 linear type (motion blur). If set to zero circular type (out of focus camera) blur assumed to be present in input frame
wn white noise to stabilize inversion. 0.0001 to 0.99.
x: For linear blur x coord of line end. Valid values are from 0 to 1/8 of frame width. Value is symmetrical to origin. For circular blur, this value is radius of blur circle. Minimum 1, max 1/8 of width;
y : y coord of line end - 1/8 to 1/8 of frame height. For circular blur this is ignored;
fr : fr is radius of filter that will be designed , specified as as %age of half of smaller dimension of frame. Valid values are 5 to 20.
Scale : specify to get back original amplitudes. Trial and error. 0.000001 to 1000000.0
Severe ringing can be seen in output for restoring from large blurring.
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
#blurred image .
core.vcfreq.Blur(ret,line = 1,x = 4, y = 4)
#Sharpd image
core.vcfreq.Sharp(ret,line = 1,x = 4, y = 4, fr = 10,wn = 0.1, scale = 0.45)
ret=core.std.StackVertical(clips=[ret1,ret2])
ret.set_output()

To my index page | to down load plugin 32 bit or 64 bit | To Avisynth