pro hotpx5,im,THRESH,newim,MBOX,RBOX ; best parameters found for GC DATA images: THRESH=5, MBOX=9, RBOX=5 DG 3/28/00 ; RBOX should be odd value ; Replaces 1 or 2 pixel wide positive spikes in an image by the median of ; adjacent points in row. Pixels in which: ; 2nd derivative < THRESH*mean(abs(2nd derivative)) ; are identified as positive spikes ; IM (input/output array (# columns , # rows)) image in which positive spikes ; are to be replaced by local median. ; [THRESH (optional input scalar)] spike identification THRESHold. If argument ; is not provided, a default value will be used. ; ;14-Aug-92 ECW Tuned: THRESH=15, mwid=3, reject 1% before stdev. Fixed ; bug in reported number of pixels fixed. Added bad pixel list. ;18-Aug-92 JAV Stripped out bad pixel list logic. Sorry. if n_params() lt 1 then begin print,'syntax: hotpx5,im,[THRESH],/plot.' retall endif if n_params() lt 2 then THRESH=15 ;use default, if necessary if not(keyword_set(mbox)) then mbox=9 if not(keyword_set(rbox)) then rbox=5 ;Define useful quantities nrows = n_elements(im(*,0)) ;number of rows in image ncols = n_elements(im(0,*)) ;number of columns in image newim = im ms = median(im,MBOX,/even) sub = im - ms npix = (RBOX-1)/2 ;Loop thru pixels, fixing deviant values for i=0+npix,nrows-1-npix do begin for j=0+npix,ncols-1-npix do begin deviation = median(abs(sub(i-npix:i+npix,j-npix:j+npix)),/even) if (abs(sub(i,j)) gt 15*deviation) then begin x = where(abs(sub(i-npix:i+npix,j-npix:j+npix)) gt 15*deviation,count) ; if (count lt 4) then begin newim(i,j) = median(im(i-npix:i+npix,j-npix:j+npix),/even) ; endif endif endfor endfor end