F2Quiver, F2QuiverUV


Author V. C. Mohan
Date Feb 21, 2009
EMail: mohanvc

F2Quiver, and F2QuiverUV functions transforms 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 symmetry in frequency domain. In addition for F2Quiver, upto two Elliptic notch filters can be specified. Filters can be cascaded. 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.

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 seperate these components with an appropriate low cut (high pass) filter. A mfact parameter scales after this homomorphic filtering. Results may not e appealing

24 types of Standard filters are specified using abbrevated names as below:
First letter is either b for butterworth, or g for gaussian.
Second letter is type of symmetry: v for vertical, h for horizontal, c for circular, p for point, and l for line.
third letter is either h (high cut) or l (low cut), or b (band stop) or n( notch). For point symmetry third letter is a numeral 0 to 9.
for line symmetry band stop and notch the fourth letter is a numeral 0 to 9.
The first integer value after filter name is the cut off or central frequency. For c, l or p symmetry it is the horizontal freq and must be a positive number.
The second number is band or notch width as a %age for v , h, c symmetry. For p or l symmetry, it is the vertical frequency (can be negative). Some valid number must be specified even if this entry is not relevant for some filters (bvl, bvh,bhl, bhh,gvl, ghl, ghh, gvh).
The numeral forming part of name is used to get band or notch width.

The cutoff frequency is either a point where amplitude falls to 50%, or to 67%. Similarly band width or notch width corresponds to those points. While a notch reject has a V shape, bandstop has a U shape

The valid filter names are:
gp0, gp1, gp2, gp3, gp4, gp5, gp6, gp7, gp8, gp9
gcb, gcn, gch, gcl, gll, glh,glb0,glb1,..glb9, gln0,gln1,..gln9
bp0, bp1, bp2, bp3, bp4, bp5, bp6, bp7, bp8, bp9
bcb, bcn, bch, bcl, bll, blh,blb0,blb1,..blb9, bln0,bln1,..bln9
bvh, bvl, gvh, gvl, bhh, ghh, ghl, bhl

Degree is the Butterworth filter sharpness degree. This value is used for all Butterworth filters being used in a cascade. Gaussian filter is equivalent to a Butterworth filter of degree 1. Gaussian filters are gentler and produce no ringing. If different degrees are required for butterworth filter, then repeating them and or repeating a gaussian filter of same type and identical parameters it can be achieved for the degree will add up. For example if you specified degree as 2 and for a particular filter "bch",100,10, and you need degree of 5, "bch",100,10, "bch",100,10, "gch",100,10 will get the 2+2+1 degree.

Upto two elliptic areas can be specified as notch filters. This facility is available in F2Quiver only. Number of elliptic filters, freq coordinates along x and y of the two focii of the ellipse, factor to get major axis length and sharpness of filter need to be specified.If sharpness is 1 then Gaussian Filter is designed otherwise Butterworth is designed.

A test facility is included. In this option the power spectrum is shown in the left or right half of screen. The other half displays half of input image (unfiltered). Filters need not be specified in this option. It should be noted that the horizontal and vertical frequencies must be related to the rulers provided

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 YV12 formats are acceptable. Y values only are processedby F2Quiver, while U and V values only are processed by F2Quiver UV. Most of the parameters are same for both functions. The differences are shown in the table below. Frame height and width must be multiples of 4.


Details of parameters
Description Name Type Limits Default
Input clip clip none
Array of values sets of string and integers. First entry is any filter abbrevated name , followed by a frequency and bandwidth % age (or vertical freq) value pair. (Bandwidth is not used for low cut and high cut.but a value must be specified.
Degree of Butterworth Filters degree integer 0 to 32 2
Is this a test run? test boolean true for yes false
Is rescaling of output required? rescale boolean true or false false
gamma value to be used for spectral display scaling gamma float 1.0 is no scaling 0.1
Is this homomorphic process? morph boolean true or false false
Is spectrum to be displayed in left half of frame? left boolean true or false true
Mult factor to boost image after homomorphic filtering mfact integer 1 to 10000 255
Filter radial length frad integer 16 to half of smaller frame dimension 1/4th frame smaller dimension
Number of Elliptical Filters specified (f2quiver only) nef integer 0, 1, or 2 0
X freq of foci 1 of filter 1 (f2quiver only) f1x1 integer -256 to 256 must be specified
y freq of foci 1 of filter 1 (f2quiver only) f1y1 integer -256 to 256 must be specified
X freq of foci 2 of filter 1 (f2quiver only) f1x2 integer -256 to 256 must be specified
y freq of foci 2 of filter 1 (f2quiver only) f1y2 integer -256 to 256 must be specified
multiplier of focii distance for filter 1 (f2quiver only) mf1 float 1.0 to 2.0 1.05
filter sharpness for filter 1 (f2quiver only) sh1 integer 1 to 9 2
X freq of foci 1 of filter 2 (f2quiver only) f2x1 integer -256 to 256 must be specified
y freq of foci 1 of filter 2 (f2quiver only) f2y1 integer -256 to 256 must be specified
X freq of foci 2 of filter 2 (f2quiver only) f2x2 integer -256 to 256 must be specified
y freq of foci 2 of filter 2 (f2quiver only) f2y2 integer -256 to 256 must be specified
multiplier of focii distance for filter 2 (f2quiver only) mf2 float 1.0 to 2.0 1.05
filter sharpness for filter 2 (f2quiver only) sh2 integer 1 to 9 2
whether U values need to be processed? Not avalable for F2Quiver uu boolean true or false, both uu and vv should not be false true
whether V values need to be processed? Not avalable for F2Quiver vv boolean true or false, both uu and vv should not be false true

Usage examples:-

# test for power spectral display
F2Quiver(s, test=true,gamma=0.4)
#processing with 3 cascaded filters
F2Quiver(s, "bhh",170,50,"gp4",40,25, "blb5", 150, 20, degree= 4)
#To view designed filters on the power spectrum filter to process image and use output as input to test run.

example of test:

F2Quiver(s,test=true,gamma=0.1)


vertical bandstop filter used and part of output:
h1=F2Quiver(last,"bvb",133,20,degree=2,rescale =false)
F2Quiver(h1,test=true,gamma=0.1)


Homomorphic filtering:
F2Quiver(last,"gcl",2,50,degree=4,rescale =true,morph=true)
On left is homomorphic filtered and on right is input image



Image below is the display of frequency filter buffer, extracted from a frame of size 960 X 480, for filter statement given below. The width gets halved and so for other sizes the circular symmetry may appear as elliptical.
F2Quiver(last,"gvb",134,1,"bhh",220,20,"bp1",100,120,"gcb",95,10,"glh",50,-40,"blb1",75,60,degree=4)

gvb : gaussian vertical symmetric band stop center freq 134, band width 1%
bhh : butterworth horizontal symmetry high cut freq of 220, degree 4
bpl : butterworth point symmetry band width 1%, at freq (100,120)
gcb : gaussian circular symmetry band stop with cental freq of 95, band width 10%
glh : gaussian line symmetrical passing through origin from 50, -40 to -50,40 high cut
blb1: butterworth line through origin from 75, 60 to -75, -60 and band pass bandwidth 1 degree 4
Elliptical Notch Filter example
F2Quiver(img,nef = 2, f1x1 = 77, f1y1=-225,f1x2=77,f1y2=-180,mf1=1.25,sh1=1,f2x1=77, f2y1=27,f2x2=77,f2y2=70,mf2=1.905,sh2=5)
test=F2Quiver(test=true, morph = false, gamma = 0.1)
crop(test,0,0,360,0)

Output