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
Input Parameters
sizex — The size of the image, in pixels, in the x direction.
sizey — The 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
Noregion — If 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 Using DEFROI to Define Region. The results are shown in Modified Image.
; 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)
|
; Invert the colors of pixels that lie within specified region. g(subs) = !D.N_Colors - g(subs) ; Display the resulting image. TV, g
|