;=============================================================================== FUNCTION COSMICR, imain,ch ;---------------------------------------------------------------------------- ; Cosmic ray correction by thresholding, using spatial median filter ; limit = detection threshold in sigmas ; F. Clette, January 1998 ;---------------------------------------------------------------------------- nsigmas=3.5 ; threshold for cosmic ray detection sbin =7 ; Kernel size for median filter minthr =0.6 ; Minimum relative detection threshold ; for the brightest parts of the images this last threshold will be the highest ; one. ; at low intensities, the threshold derived from photon statistics takes over. s=size(imain) valid=WHERE(imain GT 0,cnt) IF (cnt GT 0L) THEN BEGIN s=size(imain) imalim=INTARR(s(1),s(2)) imamed=FLTARR(s(1),s(2)) t1=systime(1) imamed(valid)=MEDIAN(imain(valid),sbin) ; median used as reference ; background ; PRINT,'Elapsed : ',systime(1)-t1,' sec' imamed(valid)=imamed(valid)-EIT_DARK() t1=systime(1) imalim(valid)=imamed(valid)+EIT_DARK()+$ ( fix(nsigmas*SQRT( 2.7 + 0.2*imamed(valid) ))> $ fix(imamed(valid)*minthr) ) ; PRINT,'Elapsed : ',systime(1)-t1,' sec' hit=WHERE(imain GT imalim,ch) imacorr=imain IF (ch GT 0) THEN begin imacorr(hit)=imamed(hit)+EIT_DARK() ENDIF ENDIF ELSE ch=0L RETURN, imacorr END ;===============================================================================
Last revised: - Wed May 9 21:44:58 2007- F. Auchère