Help for FIL2

PURPOSE
fil2 is a VICAR applications program which calculates filter
weights from point spread functions, modulation transfer functions,
and optical transfer functions.  These weights are output in a
parameter dataset suitable for input to program FILTER, which
applies the weights in the spatial domain.

fil2 and FILTER are combined in the procedure FILTER2.

EXECUTION

The following is the execution statement format for FILTER2:
	fil2 PARAMS
where PARAMS includes parameters that are described in the Tutor mode.

OPERATION:

fil2 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 parameter file 
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, 
fil2 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.
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 transform is constructed from 
the following equation:
                   M-1 N-1
	WT  = 1/N  SUM SUM  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  SUM  OTF  exp( -2#i ln/N )
          l        n=0     n

where    SUM 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.  fil2 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.

EXAMPLE:

fil2 NLW=15 NSW=15 MTF=(1.,0.,.4,.2,.1,.5) SN=7.0

WRITTEN BY: J. J. Lorre        2 DEC 1974
CONVERTED TO VAX BY:    Charlie Avis
MADE PORTABLE FOR UNIX: CRS (CRI) 1-JULY-94 
CURRENT COGNIZANT PROGRAMMER:  L. W. Kamp

PARAMETERS:


WTMAX

Maximum weight value

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

See Examples:


Cognizant Programmer: