; function to determine the readout pedestal in trace images
; 
; pedestal=tracepedestal(image,h=h,imax=imax)
;
; input:   image
; output:  pedestal     value of pedestal
;          h            histogram of intensities below 1000 DN
;          imax         most likely intensity
;
function tracepedestal,image,h=h,imax=imax
; function to estimate a zero-level for image scaling
h=histogram(image,min=0,bin=1,max=1000)
dummy=max(h,imax)
; use the four corner of the image to determine the pedestal
pedestal=total(image(1:30,1:30)+image(1023-30:1023,1:30)+$
        image(1:30,1023-30:1023)+image(1023-30:1023,1023-30:1023))/(4.*30.^2)
return,pedestal
end

--------------55673C77F400B2B417E45024--

