PRO IMAGE_EVENT, event ; This is the main event handler for the IMAGE program. Common DATA, image ; What button caused the event? Find out by getting its value. Widget_Control, event.id, Get_Value=buttonValue ; Branch based on button value CASE buttonValue OF 'Sobel' : TVScl, Sobel(image) 'Roberts' : TVScl, Roberts(image) 'Boxcar' : TVScl, Smooth(image, 7) 'Median' : TVScl, Median(image, 7) 'Original Image' : TVScl, image 'Quit' : Widget_Control, event.top, /Destroy ELSE: ; Fall through the event handler ENDCASE END ; of IMAGE_EVENT *************************************************** PRO IMAGE ; This program demonstrates various image processing capabilities. ; Store the image information in a named COMMON block Common DATA, image ; Create a top-level base for this program. Give it a title. tlb = Widget_Base(Title='Image Processing Program', Column=1) ; Create a menubase as the first child of TLB to hold menu buttons. menubase = Widget_Base(tlb, Row=1) ; Create a "File" pull-down menu to hold file operation processes. filer = Widget_Button(menubase, Menu=2, Value='File') ; Create a "Quit" button to go into the "File" menu. quitter = Widget_Button(filer, Value='Quit') ; Create an "Image Processing' pull-down menu. processing = Widget_Button(menubase, Menu=2, Value='Image Processing') edge = Widget_Button(processing, Menu=1, Value='Edge Enhancement') sobel = Widget_Button(edge, Value='Sobel') robert = Widget_Button(edge, Value='Roberts') smooth = Widget_Button(processing, Menu=1, Value='Image Smoothing') boxcar = Widget_Button(smooth, Value='Boxcar') median = Widget_Button(smooth, Value='Median') orig = Widget_Button(processing, Value='Original Image') ; Create a drawbase as a child of the top-level base. drawbase = Widget_Base(tlb, Row=1) ; Create a draw widget to hold the image draw = Widget_Draw(drawbase, XSize=256, YSize=256) ; Realize the widget program Widget_Control, tlb, /Realize ; Get the value of the draw widget, which is its window index number. ; Can only be done AFTER the draw widget is realized. Widget_Control, draw, Get_Value=window_id ; Make the draw widget the current graphics window WSet, window_id ; Read the image data filename = Filepath(Subdir='training', 'ctscan.dat') OpenR, unit, filename, /Get_LUN image = BytArr(256, 256) ReadU, unit, image Free_LUN, unit ; Load a colortable and display the image LoadCT, 11 TvScl, image ; Call XManager to set up the Event Loop and manage the program XManager, 'Image', tlb, Event_Handler='Image_Event' END ; of IMAGE ***************************************************************