Help for FILTER2

PURPOSE
FILTER2 is a VICAR applications procedure which calculates filter
weights from point spread functions, modulation transfer functions,
and optical transfer functions.  It then applies the weights in the
spatial domain.
EXECUTION
The following is the execution statement format for FILTER2:
	FILTER2 IN OUT SIZE PARAMS
where IN, OUT, SIZE and PARAMS are parameters discussed in their
respective parameter sections.
OPERATION:
FILTER2 distinguishes between symmetrical and asymmetrical OTFs in the
following way.  There are two accumulation buffers, one for horizontal
OTFs fed by the MTF, HIA, PSF, and HIF keywords and the other for vertical
OTFs fed by the VIA and VIF keywords.  When both buffers contain OTFs,
they are taken in pairs starting with the first entries to those buffers,
and an asymmetrical two-dimensional OTF is generated from which one set
of weights is created.  These weights are written to the SYS000 along
with NLW, NSW, SCALE, DIVIDE, and the first RANGE data, if any.  The 
program then returns to the buffers for the next pair, etc., until the
buffers are exhausted.  If one buffer is exhausted before the other, 
FILTEr2 will assume that the user wants a symmetrical two-dimensional
OTF.  Thus, as many weight matrices are created as there are OTFs in the 
most populated buffer.  
For one-dimensional weight vectors,  NLW or NSW  must equal unity.
The OTFs must, however, be found in the horizontal buffer.
If there are no input files, the procedure will compute the weights and
print them.
FILTER2 (specifically program FIL2) uses Fast Fourier Transformations
to compute the weights.  for one-dimensional weights, a single transform
is used of length greater than the desired weight matrix but within the 
range 128 to 1024 elements.  For two-dimensional weight matrices, a 64x64
transform is used in all cases regardless of the dimensions.  The trans-
form is constructed from the following equation:
                   M-1 N-1
	WT  = 1/N   E   E  OTF  exp(-2#i[Km/M - ln/N] )
         kl        m=0 n=0   mn

or, in the one-dimensional case
                   N-1
	WT  = 1/N   E  OTF  exp( -2#i ln/N )
          l        n=0    n

where    E means summation and # is pi.

Interpolation of the one-dimensional OTF's into a two-dimensional
surface is performed with three different algorithms.  All interpolation
is performed upon the final OTF, i.e., after any reciprocals have been 
performed.
SYMMETRICAL MODE ALGORITHM
	If the symmetrical mode is used (only one OTF buffer), then
	regardless of the shape of the OTF, the surface is set equal
	to the amplitude of the OTF at the equivalent frequency position
	as measured radially outward from the DC term.
ASYMMETRICAL MODE ALGORITHM, RECT
	If the asymmetrical mode is used (both OTF buffers are populated)
	then the output surface is set equal to the smaller of the two 
	closest one-dimensional OTF values.
ASYMMETRICAL MODE ALGORITHM
	If the asymmetrical mode is used and the OTFs are greater than 
	unity in places, the surface is set equal to a combination of the
	amplitude of both OTFs at the equivalent radial frequency.  Each
	amplitude is weighted based on the square of the distance of the
	point from the horizontal or vertical.
The OTF computed from the raw weights does not necessarily agree with the OTF 
desired.  FILTER2 automatically adjusts the central weight and the DIVIDE
parameter so that the resultant OTF is equal to the input OTF at zero 
frequency.  Adjusting the central weight does not distort the OTF but
merely displaces it up or down by a constant.  The DIVIDE parameter mul-
tiplies the OTF so that there is no amplitude distortion due to scaling
the weights to large integers.  The formulae are:
	new central wt = wt sum - old central wt + OTF(0)*64*64
	DIVIDE = SCALE * 64*64 / abs(largest wt)
where SCALE is the real-to-integer conversion factor, usually set to 32000.
EXAMPLES:
FILTER2 IN OUT NLW=15 NSW=15 MTF=(1.,0.,.4,.2,.1,.5) SN=7.0
WRITTEN BY: j. j. lorre        2 DEC 1974
CURRENT COGNIZANT PROGRAMMER:  charlie avis
REVISION: 11 MAR 1975
          29 FEB 1996 Made portable f.f.Moss

PARAMETERS:


INP

The input image file

OUT

The output filtered image file

SIZE

Vicar size field

SL

size field starting line

SS

Size field starting sample

NL

Size field number of lines

NS

Size field number of samples

WTMAX

Maximum weight value Valid: HALF.

PRINT

Prints the computed OTF

RECT

Indicates RECT algorithm

DIVIDE

Scaling paramater upon output

NLW

Size of weight matrix in lines

NSW

Size of weight matrix in samples

SCALE

Defines the linear output scaling

MTF

Input pairs of amplitude and freq

HIA

Horizontal amplitude values

HIF

Horizontal frequency values

VIA

Vertical amplitude values

VIF

Vertical frequency values

SN

Signal-to-noise ratio

RANGE

Dn interval over which weights apply

PSF

Input point spread function

OFORM

Output data format. (Default: input format)

See Examples:


Cognizant Programmer: