# F2Quiver & F2QTest

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

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 radial length can be specified. To avoid wrap around error, internally the transforms are in an extended frame size.

filter values specified must correspond to those seen in test 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( or 20) and 10. The maximum value will correspond to 250 (256 being NYQUIST frequency assumed)

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

Only YUY2 and Planar (YV12 only by 2.5 version) formats are acceptable. Y values only are processed by F2Quiver and F2QTest. Input frame height and width must be multiples of 4. The two functions have identical parameter list. The parameter specifications have been changed for 2.6 version and are not compatible with 2.5 version dll.

 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 Filter radial length. Ignored by F2QTest frad integer 16 to 128 in steps of 4 and less than 1/8 of frame dimension 32

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)