procedure imgstat (image) file image ="" {prompt="image name"} int npix =0 {prompt="number of image pixels"} real mean =0. {prompt="average pixel value"} real midpt =0. {prompt="midpoint (median) pixel value"} real stddev =0. {prompt="standard deviation (sigma)"} real min =0. {prompt="minimum pixel value"} real max =0. {prompt="maximum pixel value"} real sum =0. {prompt="sum of all pixels"} real rmode =0. {prompt="mode of the pixel values"} real lower =INDEF {prompt="lower cutoff for pixel values"} real upper =INDEF {prompt="upper cutoff for pixel values"} real binwidth=0.1 {prompt="bin width of histogram in sigma"} bool domode =no {prompt="calculate mode of image pixels?"} bool verbose =no {prompt="print results to screen?"} # @(#) task imgstat Author: M. Franx/ revised by R.A. Jansen # @(#) # @(#) task imgstat runs task 'imstat' and loads the statistical parame- # @(#) ters into task parameters, which can be used by other procedures # @(#) (e.g. imgstat.mean). # @(#) Jun 19 2002 -- Added (temporary) test to distinguish between 2.11 # @(#) and 2.12 version of 'imstatistics'. RAJ. begin file input, tmpoutput string cline, clo, chi, fields real rmean, rstddev, rmin, rmax, rmdpt int l1, rnpix bool domod, new input = image domod = domode rnpix = 0 rmean = 0. rstddev = 0. rmin = 0. rmax = 0. rmdpt = 0. rmode = 0. fields = "npix,mean,stddev,min,max,midpt" if (domod) { fields = fields//",mode" } new = no # Are we running IRAFv2.11.3 or IRAFv2.12? sysinfo() if ( sysinfo.version == 'NOAO/IRAF V2.12EXPORT' ) { new = yes } # Run 'imstat' ... tmpoutput = mktemp("imgstat") if (new) { imstat (input, fields=fields, lower=lower, upper=upper, nclip=0, lsigma=3., usigma=3., binwidth=binwidth, format=no, cache=yes, > tmpoutput) } else { imstat (input, fields=fields, lower=lower, upper=upper, binwidth=binwidth, format=no, > tmpoutput) } # Read back the output of 'imstat'; variable 'l1' is a dummy list = tmpoutput l1 = fscan(list,rnpix,rmean,rstddev,rmin,rmax,rmdpt,rmode) npix = rnpix # Check whether there where any pixels in the given range if (rnpix == 0) { if (lower==INDEF) { clo = "INDEF" } else { clo = str(lower) } if (upper==INDEF) { chi = "INDEF" } else { chi = str(upper) } cline = "No pixels with values between "//clo//" and "//chi error(1, cline) } # Return the statistics as task parameters... npix = rnpix mean = rmean midpt = rmdpt sum = rmean*rnpix if (npix > 1) { stddev= rstddev min = rmin max = rmax } else { stddev= 0. min = mean max = mean } image = input # Log results to the screen if (verbose) { print (str(input)//":") print ("npix mean stddev min max midpt rmode sum") print (npix, mean, stddev, min, max, midpt, rmode, sum, ) } # Clean up delete (tmpoutput, yes, verify=no) list = "" end