pro SingleImages3,Log db='DB2' ; 2005.01.16, CSee, for DB, and eliminates sqrt streach on pngs ; 2005.01.12, CSee, added test for Test Log ; 2005.01.05, CSee ; This program creates jpg, png and histogram equilized files of the ; images (all) in the test Log. ;____________________________________________________________________________ ;Establish the Test Log... cd,'',current=cdir & cd,cdir ;establishes cdir as current directory if n_params() eq 0 then log = cdir+'\' ;test for # of input parameters picklog: ans='' Print,'The current Test Log is: ',Log read,'Is this the one that you want to use? (y or n): ',ans if ans eq 'n' then Log=dialog_pickfile(/directory,path='c:\') lastchar=strlen(Log)-1 if strmid(Log,lastchar) ne '\' then Log=Log+'\' ;verify that it is a test Log file_ck=findfile(Log+'idx') if file_ck(0) eq '' then begin & print,string(10b),'**Not a Test Log (no idx): ',Log & goto,picklog & endif ;____________________________________________________________________________ ;check to see if Bushroe's processor has been run on this log. ;Create the output directories... if db eq 'DB' then directory='Images' else directory='Images2' Output=t_mkdir(Log+directory) Output=t_mkdir(Log+directory+'\HRI') Output=t_mkdir(Log+directory+'\MRI') Output=t_mkdir(Log+directory+'\SLI') Output=t_mkdir(Log+directory+'\HRI\jpeg') Output=t_mkdir(Log+directory+'\HRI\png') Output=t_mkdir(Log+directory+'\HRI\histeq') Output=t_mkdir(Log+directory+'\MRI\jpeg') Output=t_mkdir(Log+directory+'\MRI\png') Output=t_mkdir(Log+directory+'\MRI\histeq') Output=t_mkdir(Log+directory+'\SLI\jpeg') Output=t_mkdir(Log+directory+'\SLI\png') Output=t_mkdir(Log+directory+'\SLI\histeq') ;____________________________________________________________________________ ;List Image Files... cd,Log+db+'\Image' files=t_getfil('*MMX_*') ;spawn,'lsf',files,/noshell 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 array_sort,files ;sorts files in assending order times=dblarr(nfiles) ;an array containing the mission time of each file in seconds. for i=0,nfiles-1 do times(i)=seconds(strmid(files(i),13,13)) print,'The number of Images in this log is: ',sstr(nfiles),' (1 thru ',sstr(nfiles),')' print,'Working, please wait...' wait,1 ;;;____________________________________________________________________________ ;;;Find time of first MRI... ;;close,1 ;;openr,1,Log+'Science_Summary_M' ;;MRItime=0 ;Mission time of first MRI in seconds ;;line='' ;;readline: ;;while not eof(1) do begin ;;readf,1,line ;;if strpos(line,'Medium near surface') eq -1 then goto,readline ;;MRItime=seconds(strmid(line,1,13)) ;;goto,foundtime ;;endwhile ;;close,1 ;;foundtime: ;;if mritime eq 0 then begin & print,'No MRIs were found!' & goto,exit & endif ;;;stop ;;files=files(where(times ge MRItime)) ;only the files below the MRI start altitude ;;s=size(files) ;;nfiles=fix(s(1)) ;____________________________________________________________________________ ;Initalize... 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 space=1.5 ;x spacing in inches sf=.75 ;scale factor (scales the size of the images on the page) ypos=0.5 ;sets the y position for each row ff=-1 ;flag for flat fields, 1=>enabled, -1=>disabled p0=intarr(176,256) ;MRI frame 176x256 or 254 p1=intarr(128,256) ;SLI frame 128x256 or 254 p2=intarr(160,256) ;HRI frame 160x256 or 254 hight=[256,256,256] ;hight of the three images n=0 ;next file to use counter dot='.' again: ;print,dot,format='($,a1)' ;____________________________________________________________________________ ;read in files... d_read,files(n),h,p0 type=d_value(h,96) ;21=MRI,22=SLI, 23=HRI case type of 0: itype='\HRI' 1: itype='\MRI' 2: itype='\SLI' 3: itype='\HRI' 4: itype='\MRI' 5: itype='\SLI' 21: itype='\MRI' 22: itype='\SLI' 23: itype='\HRI' else: itype='Unknown' endcase imno=fix(strmid(files(n),2,5)) ;;;____________________________________________________________________________ ;;;find three matching files... ;; filetime=strmid(files(n),13,13) ;; ;stop ;; triplet_files=t_getfil('*'+filetime+'*') & siz=size(triplet_files) & nfiles2=siz(1) ;; imno=intarr(3) ;actual image number from file name ;; for i=0,nfiles2-1 do imno(i)=fix(strmid(triplet_files(i),2,5)) ;; if nfiles2 ne 3 then print,'Not a complete triplet',imno ;; array_sort,triplet_files ;sorts files in assending order ;; for i=0,nfiles2-1 do begin ;; d_read,triplet_files(i),h,p ;read in each image in order ;; s=size(p) ;; hight(i)=s(2) ;; type=d_value(h,96) ;21=MRI,22=SLI, 23=HRI ;; case type of ;; 21: p0=p ;; 22: p1=p ;; 23: p2=p ;; else:print,'type of ',triplet_files(i),' is unknown',type ;; endcase ;; ;; endfor ;____________________________________________________________________________ ;condition data... ;remove hot pixels & cosmic rays (less than 15 pixels greater that 6 sigma) index=where(p0 gt mean(p0)+6.*stdev(p0)) if index(0) ne -1 then begin siz=size(index) if siz(1) le 15 then p0(index)=Max(p0(where(p0 le mean(p0)+6.*stdev(p0)))) endif ;;scale each from 0 min to 4095 max (skip if all zeros = missing image)... ;if mean(p0) ne 0 then p0=(P0-min(p0))*4095./(max(p0)-min(p0)) p0=rotate(p0,2) ;right side up ;____________________________________________________________________________ ;write images to disk... ;1-jpeg with 2.5xAve stretch ;stop pout=bytscl(p0,min=min(p0),max=2.5*mean(p0)0 maxpt=max(pout2) if min(pout) eq 0 and max(pout) eq 0 then peq=pout else peq=hist_equal(pout2,minv=minpt,maxv=maxpt,top=255) outfile2=Log+directory+itype+'\histeq\image.'+sstr(imno)+'.jpg' write_jpeg,outfile2,peq,quality=100 ;3-png with min to max < (mean+4 sigma) stretch ;pout3=p0^.5 pout3=p0 pout3=pout3*21845.0/mean(pout3) ;scale average up to 1/3 of 16 bits sigma3=stdev(pout3,avep3) index=where(pout3 gt avep3+4.*sigma3) ;;print,min(pout3),avep3,max(pout3),sigma3 if index(0) eq -1 then goto,skip2 pout3(index)=max(pout3(where(pout3 le avep3+4.*sigma3))) ;chops off histogram above 4 sigma skip2: minpt=min(pout3)>0 maxpt=max(pout3) p_png=uint(65535d0*(double(pout3)-double(minpt))/(double(maxpt)-double(minpt))) outfile3=Log+directory+itype+'/png/image.'+sstr(imno)+'.png' write_png,outfile3,p_png ;;print,minpt,mean(pout3),maxpt,stdev(pout3) n=n+1 ;increment file number if n lt nfiles then goto,again ;if not all files are read, then keep going... exit: Print,'Done!' cd,Log end