FQ2d


Author V. C. Mohan
Date Jan 6, 2013
EMail: mohanvc

FQ2d function 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. Filters can be cascaded. All these filters are available for HomoMorphic proceesing option as well

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.

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.(By repeating a filter, its degree will add. using a combination of Gauss and butterworth filters of same type and parameters, any degree can be obtained.

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. Depending on the readability considerations ( dimensions of width and height of frame)ruler may have any of the graduations for frequency values of 100, 50 20 and 10. The maximum value at the edge is 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 use with caution. 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 processed.


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

Usage examples:-

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

example of test:

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


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


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



Below image 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.
FQ2d(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