Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/contour_draw.pro'
;+
; NAME:
; contour_draw
; PURPOSE:
; Draw the contours of image as requested in structure image_spec.
; (this is called by pro contour_mosaic)
; CALLING:
; contour_draw, image, xcoor, ycoor, image_spec
; INPUTS:
; image = 2-D array of data
; xcoor, ycoor = x & y coordinate vectors from contour_mosaic.
; image_spec = structure with contour display specifications.
; KEYWORDS:
; HARDCOPY = optional structure variable giving hardcopy specifications.
; RESULTS:
; Contours of image are drawn.
; COMMON BLOCKS:
; common adjct_map, color_map
; common HC_color, grey_map, color_trans
; EXTERNAL CALLS:
; function Min_Curv_Surf (to get smoother contours)
; PROCEDURE:
; Call "contour" with appropriate parameters, or if Spline is requested,
; first call Min_Curv_Surf to get higher resolution image,
; and then call contour draw recursively, to get smoother contours.
; HISTORY:
; written: Frank Varosi NASA/GSFC 1990-92.
; F.V.1991, added contour Line thickness and spline options.
; F.V.1992, added contours on/off option.
; F.V.1994, generalized contour specs for Lin/Log.
; F.V.1997, use Min_Curv_Surf to get smoother contours when "Spline" set.
; F.V.1998, verify that levels are unique.
;-
pro contour_draw, image, xcoor, ycoor, image_spec, HARDCOPY=HC
common adjct_map, color_map
common HC_color, grey_map, color_trans
common contour_draw, nsubpix
if (image_spec.scaling EQ "Log10") then cs = image_spec.contour_Log $
else cs = image_spec.contour
if NOT (image_spec.options.show_contours) OR (cs.NLev LE 1) then return
if (cs.Spline GT 0) then begin
sz = size( image )
nxi = sz(1)
nyi = sz(2)
npix = nxi*nyi
if (npix GT 1000) then begin
print,string(7b)
message,"image is TOO BIG for Min_Curve_Surf interpolation",/INF
print, nxi,nyi,npix
print," zoom to get total # of pixels < 1000"
print," skipping the interp..."
endif else if Yes_No_menu( "smooth contours will take time, do it", $
/BIN) then begin
message,"applying Min_Curve_Surf to "+strtrim(npix,2)+" pixels",/INFO
if N_elements( nsubpix ) ne 1 then nsubpix=7
nsubpix = select_number( "# sub-pixels / pixel ?",0,8,INI=nsubpix>2 )
print," sub-pixel factor = ", strtrim( nsubpix, 2 )
if nsubpix GT 1 then begin
nx = nsubpix*nxi
ny = nsubpix*nyi
print," this may take a long time..." + string(7b)
print," so, if you decide to abort then:"
print," press: cntrl-C"
print," and then at prompt IDL> return,Z"
mcs_image = Min_Curve_Surf( image, NX=nx,NY=ny,TPS=cs.Spline-1 )
sz = size( mcs_image )
nx = sz(1)
ny = sz(2)
mcs_xc = (xcoor(nxi-1)-xcoor(0))*findgen(nx)/(nx-1) + xcoor(0)
mcs_yc = (ycoor(nyi-1)-ycoor(0))*findgen(ny)/(ny-1) + ycoor(0)
imspec = image_spec
imspec.contour_Log.Spline = 0
imspec.contour.Spline = 0
contour_draw, mcs_image, mcs_xc, mcs_yc, imspec, HARD=HC
return
endif
endif
endif
ui = unique( cs.Levels(0:cs.NLev-1), NLev, /SORT )
if (image_spec.options.overlay) then begin
ncol = !D.table_size-1
Levcol = cs.Ccolors(ui) < ncol
Levfracrev = cs.Levfracrev
Nrev = round_off( NLev * abs( Levfracrev ) ) < NLev
if (Nrev GT 0) then begin
if (Levfracrev LT 0) then begin
Levcol(0) = ( ncol - Levcol(0:Nrev-1) ) $
MOD !D.table_size
endif else begin
Levcol(NLev-Nrev) = $
( ncol - Levcol(NLev-Nrev:*) ) $
MOD !D.table_size
endelse
endif
endif else Levcol = cs.Ccolors(ui)
if (!D.name EQ "PS") then begin
Levthick = replicate( cs.Cthick, NLev )
if N_struct( HC ) EQ 1 then begin
if (HC.type NE "color") then Levcol = $
grey_map( color_map( Levcol ) )
endif
endif else Levthick = replicate( 1., NLev )
if max( cs.CLabels ) GT 0 then begin
contour, image, xcoor, ycoor, LEVEL=cs.Levels(ui), $
Xstyle=5, Ystyle=5, /NOERASE, $
C_COLOR=Levcol, C_THICK=Levthick, $
C_LINE=[cs.CLines(ui)], $
C_LABEL=[cs.CLabels(ui)]
endif else begin
contour, image, xcoor, ycoor, LEVEL=cs.Levels(ui), $
Xstyle=5, Ystyle=5, /NOERASE, $
C_COLOR=Levcol, C_THICK=Levthick, $
C_LINE=[cs.CLines(ui)]
endelse
end