comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: drawing lines in IDL

Re: drawing lines in IDL
type: item
description: > > Steve Hartmann (morph@vuse.vanderbilt.edu) writes: > >> Does anyone know how to use the mouse to draw free hand lines over a >> displayed image? > You might take a look at the DEFROI function, or the DEFROI2 function that I've included below, which is a modified and enhanced version of DEFROI. I've also included DEFROIS, which simply allows you to call DEFROI2 iteratively when you want multiple ROI's. ************************************************************ ******** D E F R O I 2 ************************************************************ ******** ; DEFROI2.PRO 10-25-95 ; ;+ ; IMPORTANT NOTE: ; ; THIS ROUTINE IS OUR OWN "INTERNAL" VERSION OF THE DEFROI() IDL USER'S ; LIBRARY ROUTINE. WE HAVE MADE ADDITIONS TO THE ROUTINE, AND, ; UNFORTUNATELY, HAVE HAD TO MAKE CORRECTIONS AS WELL! ; ; Most notably, the indices of the roi returned, and any optional ; vertices returned, correspond to the ORIGINAL image, without ; the zoom factor being applied. This behavior is different ; from IDL's DEFROI() which returns indices and vertices ; that correspond to the zoomed image. ; ; ; NAME: DEFROI2 ; PURPOSE: Define an irregular region of interest of an image ; using the image display system and the cursor/mouse. ; CATEGORY: Image processing. ; CALLING SEQUENCE: ; R = Defroi(Sx, Sy, X0, Y0) ; INPUTS: ; Sx, Sy = Size of image, in pixels. ; Optional Inputs: ; X0, Y0 = Coordinate of Lower left corner of image on display. ; If omitted, (0,0) is assumed. Screen device coordinates. ; ZOOM = zoom factor, if omitted, 1 is assumed. ; OUTPUTS: ; Function result = vector of subscripts of pixels inside the region. ; Side effect: The lowest bit in which the write mask is enabled ; is changed. ; OPTIONAL OUTPUTS: ; Xverts, Yverts = Optional output parameters which will contain ; the vertices enclosing the region. These always correspond ; to the original image, without the zoom factor being applied. ; KEYWORD Parameters: ; ALT_WINDOWS = set to window ID(s) of alternate windows in which t…
creator: David Foster
date: 1998-03-31T08:00:00-00:00

Re: drawing lines in IDL
type: item
description: Steve Hartmann (morph@vuse.vanderbilt.edu) writes: > Does anyone know how to use the mouse to draw free hand lines over a > displayed image? Here is an example that involved some simple modifications of the example program to draw rubberband boxes that appears on my web page. Click and draw with the LEFT mouse button to draw free-hand lines on the image. Click and drag with the RIGHT mouse button to draw straight lines on the image. Among other things this example illustrates is how you might go about collecting points for creating a free-hand region of interest using pointers. Cheers, David *********************************************************** PRO Example_Button_Events, event ; All program button events handled here. Widget_Control, event.top, Get_UValue=info, /No_Copy ; Which button caused this event? Widget_Control, event.id, Get_Value=thisButtonValue CASE thisButtonValue OF 'Quit': BEGIN Widget_Control, event.top, /Destroy RETURN ENDCASE 'Erase Lines': BEGIN WSet, info.wid TV, BytScl(info.image, Top=info.drawColor-1) ENDCASE ENDCASE Widget_Control, event.top, Set_UValue=info, /No_Copy END ;----------------------------------------------------------- ------- PRO Example_Draw_Events, event ; All program draw widget events handled here. ; Deal only with DOWN, UP, and MOTION events. IF event.type GT 2 THEN RETURN ; Get the info structure. Widget_Control, event.top, Get_UValue=info, /No_Copy ; What kind of event is this? eventTypes = ['DOWN', 'UP', 'MOTION'] thisEvent = eventTypes[event.type] whichButton = ['NONE', 'LEFT', 'MIDDLE', 'NONE', 'RIGHT'] CASE thisEvent OF 'DOWN': BEGIN ; Which button was used? LEFT or RIGHT? info.buttonUsed = whichButton(event.press) ; Turn motion events on for the draw widget. Widget_Control, info.drawID, Draw_Motion_Events=1 ; Create a pixmap. Store its ID. Copy window contents into it. Window, /Free, /Pixmap, XSize=info.xsize, YSize=info.ysize info.pixID = !D.Window Device, Copy=[0, 0, info.xsize, info.ysize, 0, 0, info.wid] ; Ini…
creator: davidf
date: 1998-03-31T08:00:00-00:00