Viewing contents of file '../idllib/uit/pro/bakfile.pro'
PRO bakfile, infile, outfile, PATCH=patfil, DOC=doc, BASEFOG=basefog
;+
; NAME:
;	BAKFILE
; PURPOSE:
;	To perform a fog-level correction on an image, using a bilinear
;	interpolation technique.
; CALLING SEQUENCE:
;	bakfile [, infile, outfile, PATCH=patfil, /DOC, BASEFOG=basefog]
; INPUTS:
;       infile  The file containing the image to be processed.
;       outfile The output file. 
; KEYWORDS:
;	PATCH   If present, get the patch information from the specified
;	        file.  Otherwise, get it from:
;	           /usr4/uitbdr/patches/patchs.dat
;	DOC     If present and non-zero, status information concerning the
;	        processing of the image is displayed as the image is processed.
;	BASEFOG If present, this value is used as the base fog level.
;	        Defaults to 200.
; RESTRICTIONS:
;	The image MUST be a UIT image, either of the normal or of the
;	substep variety.
; PROCEDURE:
;	Fog levels are computed for the four corners of the image.  If 
;	processing a "normal" image, a series of patches are used to determine
;	these fog levels.  If a substepped image, a pixel strip along each
;	side is used.  These four fogs are then used to perform a bilinear
;	interpolation of the fog throughout the image; these interpolated
;	fogs are used to adjust the fog level to the base fog level throughout 
;	the image.
; MODIFICATION HISTORY:
;	Written by Michael R. Greason and Susan Gessner, HUGHES STX, 
;               21 November 1991.  
;-
;			Check parameters.
;
np = n_params(0)
IF (np LT 2) THEN BEGIN
	IF (np LT 1) THEN BEGIN
		infile = ''
		read, 'Enter the input filename: ', infile
	ENDIF
	outfile = ''
	read, 'Enter the output filename: ', outfile
ENDIF
;
IF (n_elements(patfil) LE 0) THEN $
	patfil = '/usr4/uitbdr/patches/patchs.dat'
IF (keyword_set(doc)) THEN doc = 1 ELSE doc = 0
IF (n_elements(basefog) EQ 0) THEN basefog = 200. ELSE basefog = float(basefog)
;
;			Read in the image.
; 
strd, im, hd, infile
;
;			Process the image.
;
baksub, im, hd, PATCH=patfil, DOC=doc, BASEFOG=basefog
;
;  			Write out the image.
;
stwrt, im, hd, outfile
;
RETURN
END