Viewing contents of file '../idllib/uit/pro/baksub.pro'
PRO baksub, im, hd, PATCH=patfil, DOC=doc, BASEFOG=basefog
;+
; NAME:
; BAKSUB
; PURPOSE:
; To perform a fog-level correction on an image, using a bilinear
; interpolation technique.
; CALLING SEQUENCE:
; baksub [, im, hd, PATCH=patfil, /DOC, BASEFOG=basefog]
; INPUTS:
; im The image array.
; hd The header array.
; 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, STX, 26 September 1991.
; BASEFOG added. MRG, STX, 8 October 1991.
; File i/o converted to image and header supplied. Susan Gessner,
; MRG, HUGHES STX, 21 November 1991.
; Selects patch file based on input image size. Nicholas Collins,
; Hughes STX, 24 Feb. 1993.
;-
; Check parameters.
;
np = n_params(0)
IF (np LT 2) THEN BEGIN
print, 'Syntax: baksub, im, hd'
RETURN
ENDIF
;
; check system architecture
;
if !version.os eq "sunos" then arch = 1 else arch = 0
;
; if no patch file is specified, select the default
; file based on image size
;
if arch then patch_path = '/usr4/uitbdr/patches/' else $
patch_path = 'uit$user2:[uitcal.baksub]'
IF (n_elements(patfil) LE 0) THEN begin
s = size(im)
s1 = s(1)
s2 = s(2)
if (s1 eq 4096) and (s2 eq 4096) then $
patfil = patch_path + 'sub_patchs.dat' else $
patfil = patch_path + 'patchs.dat'
endif
;
IF (keyword_set(doc)) THEN doc = 1 ELSE doc = 0
IF (n_elements(basefog) EQ 0) THEN basefog = 200. ELSE basefog = float(basefog)
;
; Compute the fog levels in the corners.
;
fogcomp, patfil, im, hd, fog, fogerr, doc=doc
;
; Perform the interpolation.
;
foginter, im, fog, doc=doc, basefog=basefog
;
; Update the header as if this were a BDR run.
;
tim = !stime
ftim = strmid(tim,3,3) + ' ' + strmid(tim,0,2) + ',' + strmid(tim,7,4) + ' '
ftim = ftim + strmid(tim,12,8)
l = strpos(patfil, ']')
IF (l GT -1) THEN BEGIN
n = strlen(patfil)
patfil = strmid(patfil, (l+1), (n-l))
ENDIF
;
sxaddpar, hd, 'FADJPROG', 'BAKSUB 1.0', 'FOG ADJUSTMENT PROGRAM'
sxaddpar, hd, 'FADJDTIM', ftim, ' == MMM DD,YYYY HH:MM:SS'
;
sxaddpar, hd, 'PATCHFIL', patfil, 'FOG PATCHES FILE'
;
sxaddpar, hd, 'FOGLL', fog(0), 'LOWER LEFT CORNER FOG'
sxaddpar, hd, 'FOGLLERR', fogerr(0), 'LOWER LEFT CORNER FOG ERROR'
sxaddpar, hd, 'FOGLR', fog(1), 'LOWER RIGHT CORNER FOG'
sxaddpar, hd, 'FOGLRERR', fogerr(1), 'LOWER RIGHT CORNER FOG ERROR'
sxaddpar, hd, 'FOGUL', fog(2), 'UPPER LEFT CORNER FOG'
sxaddpar, hd, 'FOGULERR', fogerr(2), 'UPPER LEFT CORNER FOG ERROR'
sxaddpar, hd, 'FOGUR', fog(3), 'UPPER RIGHT CORNER FOG'
sxaddpar, hd, 'FOGURERR', fogerr(3), 'UPPER RIGHT CORNER FOG ERROR'
;
RETURN
END