;+ ; ; NAME : ; MARK_ON_IMAGE ; PURPOSE : ; Removes an old crosshair from an image and mark a new one on it ; CALLING SEQUENCE: ; MARK_ON_IMAGE, xpos_dev, ypos_dev, $ ; color=color, xsize=xsize, ysize=ysize, $ ; mark_only=mark_only, remove_only=remove_only ; OPTIONAL INPUTS: ; XPOS_DEV, YPOS_DEV mark position in device units ; KEYWORDS : ; COLOR the color index of mark (optional input) ; xsize crosshair horizontal size (optional input, def=20) ; ysize crosshair vertical size(optional input, def=20) ; thick crosshair thickness(optional input, def=1) ; mark_only if set, only a new crosshair is marked on the image ; remove_only if set, only the old crosshair is removed. ; restore if set, the old crosshair is restored. ; EXAMPLE : ; TVSCL, DIST(200) ; MARK_ON_IMAGE, 70, 80, /mark_only ; MARK_ON_IMAGE, 70, 130, /mark_only ; MARK_ON_IMAGE, 120, 150 ; MARK_ON_IMAGE, /remove_only ; ; COMMON BLOCKS: ; mark_on_image_block ; MODIFICATION HISTORY ; March 1997 Jongchul Chae ; April 1997 J Chae Introduce keyword RESTORE ;- pro mark_on_image, xdev, ydev, restore=restore, $ mark_only=mark_only, remove_only=remove_only, $ color=color, xsize=xsize, ysize=ysize, thick=thick common mark_on_image_block, mark if n_elements(xsize) eq 0 then xsize=20 if n_elements(ysize) eq 0 then ysize=20 if n_elements(mark_only) eq 0 then mark_only=0 if n_elements(remove_only) eq 0 then remove_only=0 if n_elements(thick) eq 0 then thick=1 if n_elements(mark) ne 0 then begin if keyword_set(restore) then begin mark1=mark ;mark1.himg=tvrd(mark.hx, mark.hy, $ ; n_elements(mark.himg(*,0)), n_elements(mark.himg(0,*))) ;mark1.vimg=tvrd(mark.vx, mark.vy, $ ; n_elements(mark.vimg(*,0)), n_elements(mark.vimg(0,*))) tv, mark.himg*0+mark.color, mark.hx, mark.hy tv, mark.vimg*0+mark.color, mark.vx, mark.vy mark=mark1 return endif if not mark_only then begin tv, mark.himg, mark.hx, mark.hy tv, mark.vimg, mark.vx, mark.vy endif endif if remove_only then return x2=(xdev+xsize/2)<(!d.x_vsize-1) hx=(xdev-xsize/2)>0 hy= ydev-thick/2 hsize=x2-hx+1 himg = tvrd(hx,hy, hsize, thick) y2=(ydev+ysize/2)<(!d.y_vsize-1) vy=(ydev-ysize/2)>0 vx=xdev-thick/2 vsize=y2-vy+1 vimg = tvrd(vx,vy, thick, vsize) if n_elements(color) eq 0 then begin m=median([himg, reform(vimg)]) low = m le 128 color= !d.table_size*low endif mark={himg:himg, hx:hx, hy:hy, vimg:vimg, vx:vx, vy:vy, color:color} tv, himg*0+color, hx, hy tv, vimg*0+color, vx, vy end