function destripe, imgs, colval, badpix = badpix, help = help ;+ ; Destripe images by finding 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 ; 03/24/99 (MCL): won't subtract a BADVAL value from columns ; uses ITERSTAT median ;- 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 print,form='($,"image: ")' for j=0,npics-1 do begin print,form='($,A," ")',strc(j) for i=0,ncols-1 do begin col = imgs(i,*,j) if not(keyword_set(badpix)) then begin iterstat,col,istat,nsigrej=2.0,/silent colval(i,j)=median(col) ; colval(i,j) = median(col) $ endif 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 if (colval(i,j) ne BADVAL) then $ outimgs(i,*,j) = imgs(i,*,j) - colval(i,j) ; 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