PRO simstretch,image,testimage,factor,lostcols,dmin,dmax,absd $ ,DEBUG=debug,DISPLAY=display,TIMING=timing IF KEYWORD_SET(timing) THEN t0=SYSTIME(1) COMMON keeper,im,ncols,nrows,tim,tmax,tmin,lastfactor,nscols,scol,srow,stretch IF N_PARAMS() LT 2 THEN BEGIN PRINT,'Usage: simstretch,imname,testname,factor,lostcols,dmin,dmax,absd $' PRINT,' ,/debug,/display' RETURN ENDIF IF N_ELEMENTS(factor) EQ 0 THEN factor=101./47. IF N_ELEMENTS(lostcols) EQ 0 THEN lostcols=2.*(factor*84-(128+33)) IF KEYWORD_SET(debug) THEN BEGIN PRINT,image PRINT,testimage PRINT,factor PRINT,lostcols ENDIF IF N_ELEMENTS(im) EQ 0 THEN BEGIN rdkimg,image,hb,im im=stdsize(im) imsize=SIZE(im) ncols=imsize(1) nrows=imsize(2) ENDIF IF N_ELEMENTS(tim) EQ 0 THEN BEGIN rdkimg,testimage,thb,tim tim=stdsize(tim) tmax=MAX(tim,MIN=tmin) ENDIF IF N_ELEMENTS(lastfactor) EQ 0 THEN lastfactor=-1 IF factor NE lastfactor THEN BEGIN nscols=CEIL(factor*ncols) scol=REBIN(FINDGEN(nscols)/factor,nscols,nrows) srow=REBIN(FINDGEN(1,nrows),nscols,nrows) stretch=BILINEAR(im,scol,srow) lastfactor=factor ENDIF copy=stretch(0:ncols-1,0:nrows-1) shstretch=SHIFT(stretch,-(ncols+lostcols)) copy(*,*)=copy(*,*)+shstretch(0:ncols-1,0:nrows-1) cmax=MAX(copy,MIN=cmin) cmod=(FLOAT(copy-cmin)/(cmax-cmin))*(tmax-tmin)+tmin diff=cmod-tim dmin=MIN(diff,MAX=dmax) absd=mean(ABS(diff)) IF KEYWORD_SET(display) THEN tvsi,diff,ct=0 IF KEYWORD_SET(timing) $ THEN PRINT,STRING(SYSTIME(1)-t0,FORMAT='(F4.2," seconds elapsed")') IF KEYWORD_SET(debug) THEN STOP RETURN END