pro images,log db='DB2' ;DB or DB2? ;pc version, 11/23/04 ;written by csee, sometime during the middle ages... print,'' print,'This program prints images frames from the specified log to the screen.' print,'The default is the current test log.' cd,'',current=cdir & cd,cdir ;the current directory is the default log if n_params() eq 0 then log = cdir+'\' ;test for # of input parameters print,'' print,'The operant Test Log is: ',log ;____________________________________________________________________________ ;List Files... ;files=findfile(log+'/DB/Image/*', count = nfiles) ;wont work for many files ;spawn,'lsf '+log+'/DB/Image/*',files ;causes /bin/lsf: Arg list too long. err sometimes cd,log+db+'\Image\',current=cdir ;spawn,'lsf ',files files=file_search() cd,cdir s=size(files) nfiles=fix(s(1)) numfiles=sstr(nfiles) ;numfiles=short string (nfiles) if files(0) eq '' then begin & print,'No files found' & goto,exit & endif print,'The number of Images in this log is: ',sstr(nfiles) ;____________________________________________________________________________ ;Initialize... auto=1 ;for auto=1 tvscl min=0 ;the tvscl min setting max=4095 ;the tvscl max setting ilast=0 ;ilast is the previous value of i ff=-1 ;flag for flat fields, 1=>enabled, -1=>disabled menu: ;print,'' ;print,'To quit enter -1, To change minimum enter -2, to change maximum enter -3' ;print,'To autoscale enter -4, to scale from min to 2 x average enter -5' ;print,'To print the current image enter -6, to toggle flat field enter -7' ;print,'To return to this menu enter 0' print,'' print,'Enter to... Enter to... print,' 0 Get this menu -4 Autoscale, min to max print,' -1 Quit the program -5 Scale from min to 2 x average print,' -2 Change minimum -6 Print current image print,' -3 Change maximum -7 Toggle flat field -8 Jpeg image. ;____________________________________________________________________________ ;Loop that reads the desires... again: i=0 ;make i an integer print,'Pick a file (from 1 to ',sstr(nfiles),') or choose from menu: ' read,i ;i=file index if i eq 0 then goto,menu ;display menu if i eq -1 then goto, exit ;end of program if i eq -2 then begin ;set minimum of stretch auto=0 read,'Min? ',min i=ilast endif if i eq -3 then begin ;set maximum of stretch auto=0 read,'Max? ',max i=ilast endif if i eq -4 then begin ;autoscale to max and min auto=1 i=ilast endif if i eq -5 then begin ;autoscale, range = minimum to 2 x average auto=2 i=ilast endif if i eq -6 then begin ;prints current image set_plot,'ps' device,filename = 'c:\idl.ps',/times,/portrait,xsize=7.5,ysize=9,yoffset=1.0,/inches,bits_per_pixel=8 ;;device,filename = 'c:\idl.ps',/times,/portrait,xsize=4.5,ysize=5.4,yoffset=1.0,/inches,bits_per_pixel=8 if auto eq 1 then tvscl,bytscl(p,min=min(p),max=max(p),top=255) else tvscl,bytscl(p,min=min,max=max,top=255) ;p>min0 maxpt=max*21845.0/mean(p) p_png=uint(65535d0*(double(pout)-double(minpt))/(double(maxpt)-double(minpt))) outfile='C:/Image'+sstr(ilast)+'.png' write_png,outfile,p_png print,'*** Made jpeg image under C: ***' i=ilast endif if i le 0 or i gt nfiles then begin ;for i input not in range print,'Invalid value' goto,menu endif ;____________________________________________________________________________ ;Read & present file... d_read,log+db+'\Image\'+files(i-1),h,p ;determine image type and apply flat field if required... type=d_value(h,96) typ='Unknown' model=d_value(h,219) ;the model is needed to get the right flat field... case model of 'DISR1': model='DISR#1' 'DISR2': model='DISR#2' 'DISR3': model='DISR#3' else: model='Unknown' endcase if model eq 'Unknown' then begin print,'There is no flat field for model: ',d_value(h,219) ff=-1 endif if type eq 21 then begin typ='MRI ' if ff eq 1 then begin ;d_read,'\local\Imagers\Flat_Field\'+model+'\dli2_flat_field.disrsoft',hff,pff d_read,'C:\idl_programs\Flat_Field\'+model+'\dli2_flat_field.disrsoft',hff,pff if model eq 'DISR#1' then pff=pff/256. ;DISR1 Flat field is wrong p=p/pff endif endif if type eq 22 then begin typ='SLI ' if ff eq 1 then begin ;d_read,'\local\Imagers\Flat_Field\'+model+'\sli_flat_field.disrsoft',hff,pff d_read,'C:\idl_programs\Flat_Field\'+model+'\sli_flat_field.disrsoft',hff,pff if model eq 'DISR#1' then pff=pff/256. ;DISR1 Flat field is wrong p=p/pff endif endif if type eq 23 then begin typ='HRI ' if ff eq 1 then begin ;d_read,'\local\Imagers\Flat_Field\'+model+'\dli1_flat_field.disrsoft',hff,pff d_read,'C:\idl_programs\Flat_Field\'+model+'\dli1_flat_field.disrsoft',hff,pff if model eq 'DISR#1' then pff=pff/256. ;DISR1 Flat field is wrong p=p(*,2:255)/pff endif endif ilast=i p=rotate(p,2) s=size(p) ;p2=rebin(p,2*s(1),2*s(2)) ;,/sample) ;doubles image size ;p=rebin(p,2*s(1),2*s(2)) ;,/sample) ;doubles image size x=2*s(1) & y=2*s(2) p=congrid(p,x,y,/center,cubic=-0.5,/interp) ;doubles image size erase if auto eq 2 then begin & min=min(p) & max=min([2*mean(p),4095]) & endif if auto eq 1 then begin & min=min(p) & max=max(p) & endif ;stop ;tv,bytscl(p2,min=min,max=max,top=255) ;to make actual size jpegs tv,bytscl(p,min=min,max=max,top=255) print,cdir,'\Log\',db,'\',files(ilast-1) print,typ,sstr(i),' Min= ',sstr(min(p)),', Ave= ',sstr(mean(p)),', Max= ',sstr(max(p)) print,'Exposure (ms) = ',sstr(d_value(h,36)),' lamps = ',sstr(d_value(h,102)) if ff eq -1 then print,'Model= ',model,' Flat Field is off' $ else print,'Model= ',model,' Flat Field is on' print,'Streach Settings = ',min,max ;stop goto, again ;____________________________________________________________________________ ;Done... exit: print,'Done' cd,cdir end