Reference Guide > D Routines > DEFROI Function
  

DEFROI Function
Standard Library function that defines an irregular region of interest within an image by using the image display system and the mouse.
Usage
result = DEFROI(sizex, sizey [, xverts, yverts])
Input Parameters
sizex — The size of the image, in pixels, in the x direction.
sizeyThe size of the image, in pixels, in the y direction.
Output Parameters
xverts — (optional) The x-coordinates of the vertices enclosing the region.
yverts — (optional) The y-coordinates of the vertices enclosing the region.
Returned Value
result — A vector containing the subscripts of the pixels inside the region.
Keywords
NoregionIf nonzero, inhibits the return of the pixel subscripts.
Xo — The x-coordinate of the lower-left corner of the image in the window. Screen device coordinates are used.
Yo — The y-coordinate of the lower-left corner of the image in the window. Screen device coordinates are used.
Zoom — The zoom factor to be used for displaying the image. If omitted, 1 is assumed.
Discussion
DEFROI lets you interactively select a portion of an image for further processing — simply point with the mouse to the vertices of an irregular polygon containing the region of interest inside the image.
The write mask for the display is set so that only bit 0 may be written. Bit 0 is erased for all pixels and is used to draw the outline of the region. (This may have to be changed to fit the capabilities and procedures of your device.) The common block COLORS is used to obtain the current color table, which is modified and then restored. The color tables are loaded with odd values complemented and even values unchanged.
A message is printed to assist you in selecting the region with the mouse. The POLYFILLV function is used to compute the subscripts within the region.
Example
This example uses DEFROI to define a region of interest within an image. The subscripts of pixels within the region, which are returned by DEFROI, are used to invert the colors within the region of interest. The pixels outside the region are not altered. The region is shown in Figure 5-1: Using DEFROI to Define Region on page 380. The results are shown in Figure 5-2: Modified Image on page 381.
; Open the whirlpool.img file.
OPENR, unit, FILEPATH('whirlpool.img', $
   Subdir = 'data'), /Get_Lun
; Associate a 512-by-512 byte array with the file unit number 
; of whirlpool.img.
a = ASSOC(unit, BYTARR(512, 512))
; Read the galaxy image into the variable g.
g = a(0)
; Free the file unit number in unit.
FREE_LUN, unit 
!Order = 1
 
; Load the red temperature color table. Scale array containing 
; the image so that the maximum color used is !D.N_Colors.
LOADCT, 3
; Display the image.
g = BYTSCL(g, Top = !D.N_Colors)
WINDOW, 0, Xsize = 512, Ysize = 512
TV, g
; Define a region of interest using DEFROI.
subs = DEFROI(512, 512)
 
Figure 5-1: Using DEFROI to Define Region
; Invert the colors of pixels that lie within specified region.
g(subs) = !D.N_Colors - g(subs)
; Display the resulting image.
TV, g
 
Figure 5-2: Modified Image
See Also
POLYFILLV

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.