pro mean_var,name,num,size,mean,var ; ; This procedure computes the mean and variance of a set of 2-byte ; integer images acquired by a CCD camera. It accepts as inputs the ; base file name of the images, the number of images, and the number ; of pixels on a side of the (square) images. It returns two ; floating-point images, containing the mean and the variance of the ; input images, respectively. ; ; The function assumes that the images in the sequence have file ; extensions given by their position in the sequence of images, ; starting from 00. ; single=intarr(size,size) sum=lonarr(size,size) sumsq=sum for i=0,num-1 do begin ; compute file extension for i-th input image ext=get_ext(i,1) fname=name+'.'+ext ; get i-th image single=imin(fname,size) ; convert image to long-integer format to avoid overflow when squaring sing_4=long(single) ; update sum and sum of squares of images sum=sum+sing_4 sumsq=sumsq+sing_4*sing_4 endfor mean=float(sum)/num var=(num*float(sumsq)-float(sum)*sum)/(num*(num-1)) return end