procedure thist (singleImg,imgName,imgFile,abbName,extn,nb,frm,boxSize, writeFile, outStat) bool singleImg {yes,prompt="Examine only a single image?"} string imgName {"-",prompt=" Full name of that image"} string imgFile {"--",prompt=" Else image list (full or abbreviated names)"} bool abbName {no, prompt=" ---> Are image names abbreviated?"} string extn {prompt=" ---> Extension appended to abbreviated names"} int nb {30, prompt="Number of histogram bins"} int frm {1, prompt="Ximtool frame for display image"} int boxSize {70, prompt="Side-length of region for statistics?"} bool writeFile {no, prompt="Write region statistics to a file?"} string outStat {"---", prompt=" ---> File containing statistics output "} struct *flist1 struct *flist2 # list-directed structures begin # Variable Declarations: string rawName # raw (abbreviated) image name string fullName # full image name int k int j # image counters string imgjnk # junk string to store first image name int x1, x2 int y1, y2 # dimensions of imstat region int xc, yc # central coordinates of current region string reg # string containing image stat region int Nreg # counter of the number of regions string action # keystroke action string if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } if (! defpac ("lists")) { print("Package LISTS needs to be loaded.") bye } if (! defpac ("proto")) { print("Package PROTO needs to be loaded.") bye } # Cleaning up any files to be used: delete (files="temp_thist*",go_ahea+,ver-) delete (files="temp_junk",go_ahea+,ver-) if (writeFile==yes) { delete (files=outStat,go_ahea+,ver-) } k=0 # 1. Individual image: ------------------------------------------ if (singleImg==yes) { display (image=imgName,frame=frm,erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >> "temp_junk") print (" ") print (" *** "//imgName//" displayed in Ximtool frame "//frm//" ***") print (" ") print (" --> Press any key at each region and then ctrl+.") rimcursor(image=imgName,wcs="logical",wxformat="",wyformat="", cursor="",mode="ql", >> "temp_thist1") print (" ") print (" Please wait ...") print (" ") !awk '{print int($1)" "int($2)}' temp_thist1 >temp_thist2 flist2 = "temp_thist2" Nreg=0 while ( fscan(flist2, xc, yc) != EOF) { Nreg=Nreg+1 x1=xc-int(boxSize/2) x2=xc+int(boxSize/2)-1 y1=yc-int(boxSize/2) y2=yc+int(boxSize/2)-1 reg = imgName//"["//x1//":"//x2//","//y1//":"//y2//"]" print("-----------------------------------------------") print(" Region "//Nreg) print(" ") print(reg) print(" ") imhistogram(image=reg,z1=INDEF,z2=INDEF,binwidt=INDEF,nbins=30, autosca+,top_clo-,hist_ty="normal",listout-,plot_ty="box",logy-, device="stdgraph") imhistogram(image=reg,z1=INDEF,z2=INDEF,binwidt=INDEF,nbins=30, autosca+,top_clo-,hist_ty="normal",listout-,plot_ty="box",logy-, device="stdgraph") # i.e. plot it twice because of tek window refresh problem imstatistics(images=reg,fields="image,npix,mean,stddev", lower=INDEF,upper=INDEF,binwid=0.1,format+,mode="ql") # writing to STDOUT print(" ") print(" *** Hit c to continue ... *** ") print(" *** (Or q to quit.) *** ") print(" ") scan(action) # i.e. need to enter at least 1 character, otherwise error if (action=="q") { print("-----------------------------------------------") print(" ") print(" ") print("Bye.") print(" ") } if (writeFile==yes) { k=k+1 if (k==1) { imstatistics(images=reg,fields="image,npix,mean,stddev", lower=INDEF,upper=INDEF,binwid=0.1,format+,mode="ql", >> outStat) print (" ") } if (k>1) { imstatistics(images=reg,fields="image,npix,mean,stddev", lower=INDEF,upper=INDEF,binwid=0.1,format-,mode="ql", >> outStat) print (" ") } # i.e. format the top line but no others thereafter } } # end of region loop. } # 2. Sequence of images: ------------------------------------------ if (singleImg==no) { flist1 = imgFile j=0 k=0 while ( fscan(flist1, rawName) != EOF) { j=j+1 if (abbName==yes) { fullName=rawName//extn } if (abbName==no) { fullName=rawName } print(" ") print("=== 1. IMAGE DISPLAY: =====================================") display (image=fullName,frame=frm,erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >> "temp_junk") print (" ") print (" *** "//fullName//" displayed in Ximtool frame "//frm//" ***") print (" ") print (" --> Press any key at each region and then ctrl+.") rimcursor(image=fullName,wcs="logical",wxformat="",wyformat="", cursor="",mode="ql", >> "temp_thist1") print (" ") print (" Please wait ...") print (" ") !awk '{print int($1)" "int($2)}' temp_thist1 >temp_thist2 print(" ") print("=== 2. HISTOGRAM INSPECTION: ==============================") print(" ") flist2 = "temp_thist2" Nreg=0 while ( fscan(flist2, xc, yc) != EOF) { Nreg=Nreg+1 x1=xc-int(boxSize/2) x2=xc+int(boxSize/2)-1 y1=yc-int(boxSize/2) y2=yc+int(boxSize/2)-1 reg = fullName//"["//x1//":"//x2//","//y1//":"//y2//"]" print("-----------------------------------------------") print(" Region "//Nreg) print(" ") print(reg) print(" ") imhistogram(image=reg,z1=INDEF,z2=INDEF,binwidt=INDEF,nbins=nb, autosca+,top_clo-,hist_ty="normal",listout-,plot_ty="box",logy-, device="stdgraph") imhistogram(image=reg,z1=INDEF,z2=INDEF,binwidt=INDEF,nbins=30, autosca+,top_clo-,hist_ty="normal",listout-,plot_ty="box",logy-, device="stdgraph") # i.e. plot it twice because of tek window refresh problem imstatistics(images=reg,fields="image,npix,mean,stddev", lower=INDEF,upper=INDEF,binwid=0.1,format+,mode="ql") # writing to STDOUT print(" ") print(" *** Hit c to continue ... *** ") print(" *** (Or q to quit.) *** ") print(" ") scan(action) # i.e. need to enter at least 1 character, otherwise error if (action=="q") { print("-----------------------------------------------") print(" ") print(" ") print("Bye.") print(" ") } if (writeFile==yes) { k=k+1 if (k==1) { imstatistics(images=reg,fields="image,npix,mean,stddev", lower=INDEF,upper=INDEF,binwid=0.1,format+,mode="ql", >> outStat) print (" ") } if (k>1) { imstatistics(images=reg,fields="image,npix,mean,stddev", lower=INDEF,upper=INDEF,binwid=0.1,format-,mode="ql", >> outStat) print (" ") } # i.e. format the top line but no others thereafter } } # end of region loop. delete (files="temp_thist*",go_ahea+,ver-) } # end of image loop } # Cleaning up any files used: delete (files="temp_thist*",go_ahea+,ver-) print("-----------------------------------------------") print(" ") print(" ") print(" All done.") print(" ") end