Welcome to the Harris Geospatial documentation center. Here you will find reference guides and help documents.

  >  Docs Center  >  IDL Reference  >  Direct Graphics  >  DEFROI



The DEFROI function defines an irregular region of interest of an image using the image display system and the cursor and mouse. DEFROI only works for interactive, pixel oriented devices with a cursor and an exclusive or writing mode. Regions may have at most 1000 vertices.

DEFROI does not function correctly when used with draw widgets. See CW_DEFROI.

This routine is written in the IDL language. Its source code can be found in the file defroi.pro in the lib subdirectory of the IDL distribution.


; Create an image:
TVSCL, DIST(200,200)
; Call DEFROI. The cursor becomes active in the graphics window.
; Define a region and click the right mouse button:
X = DEFROI(200, 200)
; Print subscripts of points included in the defined region:


After calling DEFROI, click in the image with the left mouse button to mark points on the boundary of the region of interest. The points are connected in sequence. Alternatively, press and hold the left mouse button and drag to draw a curved region. Click the middle mouse button to erase points. The most recently-placed point is erased first. Click the right mouse button to close the region. The function returns after the region has been closed.


Result = DEFROI( Sx, Sy [, Xverts, Yverts] [, /NOREGION] [, /NOFILL] [, /RESTORE] [, X0=device_coord] [, Y0=device_coord] [, ZOOM=factor] )

Return Value

Returns a vector of subscripts of the pixels inside the region. The lowest bit in which the write mask is enabled is changed.


Sx, Sy

Integers specifying the horizontal and vertical size of image, in pixels.

Xverts, Yverts

Named vectors that will contain the vertices of the enclosed region.



Set this keyword to inhibit the return of the pixel subscripts.


Set this keyword to inhibit filling of the defined region on completion.


Set this keyword to restore the display to its original state upon completion.


Set this keyword equal to X coordinate of the lower left corner of the displayed image (in device coordinates). If omitted, the default value (0) is used.


Set this keyword equal to Y coordinate of the lower left corner of the displayed image (in device coordinates). If omitted, the default value (0) is used.


Set this keyword equal to the zoom factor. If not specified, a value of 1 is assumed.


Version History



See Also



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us