WgSImageTool Procedure

Creates a GUI with sliders allowing the user to modify pixel values of the image and get basic statistics of the image.

Usage

WgSImageTool, image

Input Parameters

image — A 2-dimensional array of any ‘real’ data type, or a 3-dimensional array of type byte.

Keywords

Binsize — A positive integer specifying the width of the bins in the histogram plots, where 1 £ Binize £ MAX(image). Values less than one will cause Binsize to be set to 1. Values greater than MAX(image) will cause Binsize to be set to the maximum value of image.

Do_tvscl — If nonzero, TVSCL is used to display the image instead of TV.

Dsize — A two element vector containing the width and height, in pixels, of the viewable area within the scroll window.

New — (Output) An associative array with the following fields: the min, max, and average of the modified image, or the min, max, and average of each RGB plane if image is 3D; a date-time field with the time the modified image was created; the modified image array. If image is 3D, then the returned image has the same interleaving as the input image had.

Noreduce — If nonzero, the reduced image (in a second window) is not displayed.

Order — If nonzero, the image is flipped about the horizontal axis.

Parent — The widget or shell ID of the parent widget (long). If parent is not specified, WgCbarTool runs on its own (i.e., in its own event loop).

Position — A two-element vector containing the position, in pixels, of
WgSImageTool's upper-left corner where [0,0] is the upper-left corner of the display.

Reduced_size — A two-element vector containing the reduced image window's width and height, in pixels.

Rposition — A two element vector containing the position, in pixels, of the reduced image window's lower-left corner, where [0,0] is the lower-left corner of the display.

Rtitle — The title that will appear on the reduced image window.

Shell — The ID of the newly created widget. If the procedure fails, zero (0) is returned.

Title — The title that will appear on the main scrolling window.

Vorder — If nonzero, the image is flipped about the vertical axis.

Wsize — A two-element vector containing the width and height, in pixels, of the scrolling window containing the main image.

Ytype — If non-zero, a logarithmic y-axis is used in the histogram plots.

Background — The background color (passed to all widgets).

Basecolor — The base color (passed to buttons, radios, and so on).

Font — The font to use for widget text.

Foreground — The foreground color (passed to all widgets).

Note:

wgsimagetool_output — A common block internal to WgSImageTool containing an associative array containing the modified image. When WgSImageTool is called stand-alone, it runs in its own event loop.Once the user clicks the "Dismiss" button, control is passed back to the calling routine as is the modified image if the New keyword was given in the call. However, if WgSImageTool is called from an existing widget application, the Tool must use this calling widget's event loop. In this case, WgSImageTool is executed and control is passed back immediately to the calling widget application before the user can click on "Dismiss" and pass back the most recent changes of the image. To allow the widget application that calls WgSImageTool to have access to the most recent version of the modified image, include this common block in the calling widget application.

Example

1) WgSImageTool run as a stand-alone application

climber = IMAGE_READ(GETENV('RW_DIR') + '/image-2_0/data/rockclimber24.jpg')
; Font choice syntax different for Windows or UNIX...
IF STRMATCH(GETPLATFORM(), 'win') THEN fnt = 'Forte, 10' $
   ELSE fnt='-adobe-*-bold-*-*-*'
; Interactively modify pixels then exit and access modified image 
; through the variable z
WgSImageTool, pixels, New=z, /Order, /Vorder, $
   Rposition=[100,500], Font=fnt
INFO, z, /Full
WINDOW, /Free
TV, z('image'), True=3

2) WgSImageTool called from another widget application

PRO BUTTONSCB, wid, which
   COMMON workareaID, workarea
   COMMON wgsimagetool_output, newImage
   CASE which OF
      1: BEGIN
      inputArray = ALLAN(500)
      ; Iinteractively modify pixels then exit and access
      ; modified image not through variable z but through the 
      ; common block wgsimagetool_output. 
      WgSImageTool, inputArray, Parent=workarea, $
      Shell=shell, New=z
      END
      2: BEGIN
      ; newImage will be undefined if WgSImageTool has not been
      ; called
      INFO, newImage
      IF N_ELEMENTS(newImage) GT 0 THEN BEGIN
         ; if WgSImageTool has finished, the output will be an 
         ; associative array with either 5 elements (for 2D
         ; input) or 11 elements (for 3D input)
         IF N_ELEMENTS(newImage) EQ 5 OR N_ELEMENTS(newImage) $
         EQ 11 THEN BEGIN
            WINDOW, /Free
            INFO, newImage, /Full
            TV, newImage('image'), True=3
         ENDIF 
      ENDIF ELSE BEGIN
         PRINT, STRING(7B)
         PRINT, $
         'Processing has not been started or is not complete'
      ENDELSE
      END
   ENDCASE
END
PRO WGSIT_TEST
   COMMON workareaID, workarea
   COMMON wgsimagetool_output, newImage
   topShell = WwInit('WgSImageTool_test','WgSImageTool_test',$
      workarea, /Vertical, Position=[256,256], Spacing=5, $
      Height=100, Width=200)
   buttons = WwButtonBox(workarea,['Call WgSImageTool',$
      'View the result'],'BUTTONSCB') 
   status=WwSetValue(topShell, /Display)
   WwLoop
END

See Also

TV, TVSCL

For more information about how to write an application program based on PV‑WAVE Widgets or Widget Toolbox, refer to the PV‑WAVE Application Developer’s Guide.