function destripe,imgs,colval, badpix = badpix, help = help ;+ ; Destripe images by finding the median of each column ; or row and subtracting it. ; ; If a bad pixel mask is passed, the bad pixels are excluded in ; calculating the striping level of each column. ; ; INPUTS: ; imgs input images (1 or more) ; ; OUTPUTS ; colval value removed from each column ; ; OPTIONAL KEYWORD INPUTS ; badpix bad pixel mask (0=bad, !0=good) ; ; RETURNS ; outimgs destriped images ; ; Written by M. Liu (UCB): 7/27/95 ; 05/30/97 (MCL): preserves BADVAL pixels ;- BADVAL = -1e6 if n_params() lt 1 or keyword_set(help) or n_elements(imgs) eq 0 then begin print,'function destripe(imgs,{colval},[badpix=],[help])' retall endif ; initialize sz=size(imgs) nrows = sz(2) ncols=sz(1) if sz(0) eq 3 then npics=sz(3) else npics=1 outimgs=fltarr(ncols,nrows,npics) colval=fltarr(ncols,npics) ; loop through image by image, column by column for j=0,npics-1 do begin for i=0,ncols-1 do begin col = imgs(i,*,j) if not(keyword_set(badpix)) then $ colval(i,j) = median(col) $ else begin w = where((badpix(i, *) ne 0) or (col ne BADVAL), ng) if (ng gt 0) then $ colval(i, j) = median(col(w)) endelse outimgs(i,*,j) = imgs(i,*,j) - colval(i,j) endfor endfor ; preserve BADVAL pixels wbad = where(imgs eq BADVAL, nbad) if (nbad gt 0) then $ outimgs(wbad) = BADVAL return, outimgs end