F2Quiver & F2QTest


Author V. C. Mohan
Date May 2021
EMail: mohanvc

These functions operates in frequency domain and requires for 32 bit avisynth+ FFTw3 32 bit dll or for 64 bit avisynth+ FFTw3 64 bit dll. As these dll s are not thread safe this function operates in MT_SERIALIZED state.

F2QTest displays frequency spectra to enable deriving parameters to reduce undesirable regular noise. F2Quiver function transform image into 2d frequency domain, applies filters and transforms back into image domain. Gaussian or Butterworth band stop, lowcut, high cut and notch filters are designed with circular, or vertical, or horizontal, or point or line(fan) symmetry in frequency domain. All these filters are available for HomoMorphic proceesing option as well

filter values specified must correspond to those seen in F2Qtest display. Freq depending on type of filter correspond to center of notch freq, highest freq of low cut or lowest freq of high cut or lower freq of band or lower angle of a fan filter, or xfreq of a point Similarly the second freq value corresponds to high freq end of band, or higher angle of fan, or y freq of point. Even though disregarded by low cut, high cut or notch filters, a value must be specified at this position.

Homomorphic filtering :- The input image can be considered as the multiplication of incident light and the reflectivity of objects. While incident light varies usually slowly, the reflectivity varies more quickly. Homomorphic filtering is done to separate these components and specifying an appropriate low cut (high pass) filter.Scaling may be needed.

Standard filters are specified by sets of 5 integers:
First Integer is symmetry 1, Circular, 2. Horizontal, 3, vertical, 4. Linear Fan, 5. Point
Second Integer is type 1. low cut, 2. High cut, 3. Band Pass, 4, Band stop, 5. Notch.
Third Integer is Freq1( freq of lowcut or highcut) ( notch freq)(low freq of band) or X freq coordinate of point or angle1 for linear fan
Fourth Integer is freq2 .( high freq of band)(or angle2 for linear fan)or y freq coordinate of point
Fifth integer is Degree of sharpness. 0 to 24. If 0 Gaussian filter otherwise Butterworth filter is designed.
Up to 12 such sets can be specified and they will be cascaded.

In case of Fan filter, angle1 and angle2 are to be specified in place of freq1 and freq2. The Fan must wholly lie within 1 to 89 degrees or 91 to 179 degrees. For band pass or reject angle1 must be less than angle2. The Fan filter is designed depending upon input angles ( for 1 to 89)in 1st and 3rd quadrant or ( for 91 to 179)in 2nd and 4th quandrants surrounding the origin. So a second Fan filter may need to be specified to cover all quadrants if so desired.
Please note that all filters have diagonal quadrant symmetry as the power spectrum behaves such. ( First and third quadrants are similar so also 2nd and 4th Quadrants).

F2QTest function is a visual display of the power spectrum, shown in the left half and if a filter is specified (optional),it is shown in right half of screen. It should be noted that the horizontal and vertical frequencies must be related to the rulers provided. Depending on the readability considerations ruler may have any of the graduations for frequency values of 100, 50 and 10 or 100 and 20. 100 has a long mark, 50 has a medium length mark, while 20 or 10 have short marks.

Presence of sharp high amplitude objects (such as logos) may overwhelm the image frequencies and can make finding low level noise frequencies difficult. (Using morph=true for test can bring out these clearly). As a sharp discontinuity requires all frequencies of spectrum to be present, any filtering that affects the balance can create undesirable ringing. If possible cropping and re joining after processing may be useful in those cases.

Rescale facility is available. But Avisynth has better scaling functions. Where low frequencies and the value at origin is affected, rescaling may be needed

F2QTest and F2Quiver accepts Only Planar Y U V or packed RGB formats. F2QTest uses Y of YUV or G of RGB formats for deriving frequency spectrum. F2Quiver on the other hand filters all 3 colors of RGB and if opted ( not recommended), YUV444 formats. For other YUV formats u and v are not processed. Parameters for both functions are identical to facilitate easy switch over between these two. (parameters not used by a function are ignored and will not raise an error)


F2Quiver uses library derived from fftw3.dll which is not thread safe, but uses its own threads. So These functions operate in MT_SERIALIZED manner.
Details of parameters
Description Name Type Limits Default
Input clip clip none
Array of values sets of integers. For F2Quiver atleast one set must be specified. none
Is this homomorphic process? morph boolean true or false false
Is rescaling of output required? Ignored by F2QTest rescale boolean true or false false
gamma value to be used for spectral display scaling. Ignored by F2Quiver gamma float 1.0 is no scaling 0.05
Are u and v planes of YUV444 to be filtered? Ignored by F2QTest uv boolean true or false false
Is hamming needed? Ignored by F2QTest ham boolean true or false true
radius of filter in image domain as %age of frame smaller dimension frad float 10 to 50.0 30

Usage examples:-
# F2Quiver(5,5,60,-35,20,1,2,120,60,8,4,1,70,80,4,3,4,40,42,18,morph =false,gamma=0.04)
#F2QTest(5,5,60,-35,20,1,2,120,60,8,4,1,70,80,4,3,4,40,42,18,morph =false,gamma=0.04)
#F2QTest(4,5,105,160,14)


types of filter in freq domain
To my index page down load plugin To Avisynth