; $Id: image_cont.pro,v 1.1 1993/04/02 19:43:31 idl Exp $ pro image_cont, a, WINDOW_SCALE = window_scale, ASPECT = aspect, $ INTERP = interp, nocontours=nocontours,xval=x,yval=y,xtit=xtit,$ ytit=ytit,$ tit=tit ;+ ; NAME: ; IMAGE_CONT ; ; PURPOSE: ; Overlay an image and a contour plot. ; ; CATEGORY: ; General graphics. ; ; CALLING SEQUENCE: ; IMAGE_CONT, A ; ; INPUTS: ; A: The two-dimensional array to display. ; ; KEYWORD PARAMETERS: ; WINDOW_SCALE: Set this keyword to scale the window size to the image size. ; Otherwise, the image size is scaled to the window size. ; This keyword is ignored when outputting to devices with ; scalable pixels (e.g., PostScript). ; ; ASPECT: Set this keyword to retain the image's aspect ratio. ; Square pixels are assumed. If WINDOW_SCALE is set, the ; aspect ratio is automatically retained. ; ; INTERP: If this keyword is set, bilinear interpolation is used if ; the image is resized. ; ; OUTPUTS: ; No explicit outputs. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; The currently selected display is affected. ; ; RESTRICTIONS: ; None. ; ; PROCEDURE: ; If the device has scalable pixels, then the image is written over ; the plot window. ; ; MODIFICATION HISTORY: ; DMS, May, 1988. ; JDM, 1996. Added nocontour keyword, and ; changed tv--> tvscl in one subroutine ;- on_error,2 ;Return to caller if an error occurs sz = size(a) ;Size of image if (keyword_set(x) eq 0) then x=findgen(sz(1)) if (keyword_set(y) eq 0) then y=findgen(sz(2)) if (keyword_set(tit) eq 0) then tit=' ' if (keyword_set(xtit) eq 0) then xtit=' ' if (keyword_set(ytit) eq 0) then ytit=' ' if sz(0) lt 2 then message, 'Parameter not 2D' ;set window used by contour contour,[[0,0],[1,1]],/nodata, xstyle=4, ystyle = 4 px = !x.window * !d.x_vsize ;Get size of window in device units py = !y.window * !d.y_vsize swx = px(1)-px(0) ;Size in x in device units swy = py(1)-py(0) ;Size in Y six = float(sz(1)) ;Image sizes siy = float(sz(2)) aspi = six / siy ;Image aspect ratio aspw = swx / swy ;Window aspect ratio f = aspi / aspw ;Ratio of aspect ratios if (!d.flags and 1) ne 0 then begin ;Scalable pixels? if keyword_set(aspect) then begin ;Retain aspect ratio? ;Adjust window size if f ge 1.0 then swy = swy / f else swx = swx * f endif tvscl,a,px(0),py(0),xsize = swx, ysize = swy, /device endif else begin ;Not scalable pixels if keyword_set(window_scale) then begin ;Scale window to image? tvscl,a,px(0),py(0) ;Output image swx = six ;Set window size from image swy = siy endif else begin ;Scale window if keyword_set(aspect) then begin if f ge 1.0 then swy = swy / f else swx = swx * f endif ;aspect ; I changed the following line to read 'tvscl,...' instead of 'tv,...' ; --JDM 11/19/96 tvscl,poly_2d(bytscl(a),$ ;Have to resample image [[0,0],[six/swx,0]], [[0,siy/swy],[0,0]],$ keyword_set(interp),swx,swy), $ px(0),py(0) endelse ;window_scale endelse ;scalable pixels skipimage: mx = !d.n_colors-1 ;Brightest color colors = [mx,mx,mx,0,0,0] ;color vectors if !d.name eq 'PS' then colors = mx - colors ;invert line colors for pstscrp if (keyword_set(nocontours) eq 0) then $ contour,a,x,y,/noerase,/xst,/yst,$ ;Do the contour pos = [px(0),py(0), px(0)+swx,py(0)+swy],/dev,$ c_color = colors ,xtit=xtit,ytit=ytit,tit=tit $ else contour,a,x,y,/noerase,/xst,/yst,$ ;Do the contour pos = [px(0),py(0), px(0)+swx,py(0)+swy],/dev,$ c_color = colors ,/nodata,xtit=xtit,ytit=ytit,tit=tit return end