Computing for Imaging Science SIMG726 - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Computing for Imaging Science SIMG726

Description:

Open Class Time for Project Consulting. Rolando V. Raque o. 15. Syllabus. Class #18 ... Shows how to create a draw widget for image display ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 49
Provided by: cis58
Learn more at: http://www.cis.rit.edu
Category:

less

Transcript and Presenter's Notes

Title: Computing for Imaging Science SIMG726


1
Computing for Imaging Science (SIMG-726)
2
Gift Quiz - Who is RTM?
  • What did his father do?

3
Syllabus after Holiday Break
  • Class 6 - Today
  • Widget Programming Review
  • Assignment 2 (Check Website for details)
  • Combine Assignment 1 into Assignment 2
  • Create a widget program that will read in a PGM
    file that will display the image statistics of a
    user defined rectangular region.
  • Pay particular attention to non-interactive
    interface
  • Program the one-dimensional and two-dimensional
    special functions Rect and Gaus

4
Syllabus
  • Class 7
  • Widget Programming
  • Event Handlers

5
Syllabus
  • Class 8
  • Assignment 1 Due
  • Shell Programming
  • UNIX Quotes
  • Making UNIX commands of IDL Programs
  • Mystery Image Techniques
  • QUIZ
  • Topics
  • dd, od, strings, which, wc

6
Syllabus
  • Class 9
  • Debugging in IDL
  • More Widget Examples

7
Syllabus
  • Class 10
  • Special Function Implementation
  • Midterm Exam Review
  • Quiz

8
Syllabus
  • Class 11
  • Midterm Exam (Take home 1 week to do)
  • Image Processing Implementations

9
Syllabus
  • Class 12
  • Image Processing Implementations
  • AWK, SED, and Makefiles
  • Quiz

10
Syllabus
  • Class 13
  • Final Project Updates
  • IDL Pointers

11
Syllabus
  • Class 14
  • Assignment 2 Due
  • Modal Widgets

12
Syllabus
  • Class 15
  • 3D Graphics Concepts

13
Syllabus
  • Class 16
  • More 3D Graphics

14
Syllabus
  • Class 17
  • Open Class Time for Project Consulting

15
Syllabus
  • Class 18
  • Project Presentation Session 1

16
Syllabus
  • Class 19
  • Project Presentation Session 2
  • Final Project Submissions Due

17
Widget Events
18
Widget Event
  • A widget event is basically a reaction to some
    form of user input
  • Mouse clicks, drags, and movement
  • Keyboard input
  • Button push
  • An widget event generates a structure which
    identifies the widget that caused the event and
    other relevant information.

19
IDL Event Structure
  • All IDL Events will generate a named structure
    that is guaranteed to have the following
  • A structure name
  • The ID of the widget that generated the event
  • The ID of the base to which the above widget
    belongs
  • The ID of the widget with which an event handler
    is associated.

20
Event Handler
  • Special Processing functions (Event Handlers)
  • capture and appropriately interpret those events.
  • single button program
  • beep when pressed.
  • First, need to create and destroy a widget by
    creating a Quit Button

21
Create the Quit Button Widget
  • pro quit_button
  • baseWidget_Base(column1,titleQuit Button)
  • button Widget_Button( base, valueQuit )
  • Widget_Control, base, /realize
  • end

22
Quit Button Widget Event HandlerMethod 1
  • pro quit_button_event, event
  • Widget_Control, event.top, /destroy
  • end
  • pro quit_button
  • baseWidget_Base(column1,titleQuit Button)
  • button Widget_Button( base, valueQuit)
  • Widget_Control, base, /realize
  • Xmanager, quit_button', base,
    event_handlerquit_button_event'
  • end

23
Quit Button Widget Event Handler Method 2
  • pro quitter, event
  • Widget_Control, event.top, /destroy
  • end
  • pro quit_button_event, event
  • end
  • pro quit_button
  • baseWidget_Base(column1,titleQuit Button)
  • buttonWidget_Button(base, valueQuit,
    event_proquitter )
  • Widget_Control, base, /realize
  • Xmanager, quit_button', base,event_handlerqui
    t_button_event'
  • end

24
Button Widget Example
  • For the sake of presentation space, we will not
    be including the quit button in the following
    code.
  • You should, however, include it so that you can
    gracefully get rid of the widgets.

25
Create the Button Widget
  • pro beeper
  • baseWidget_Base(column1, title"Beep" )
  • buttonWidget_Button(base,value"Press Here")
  • Widget_Control, base, /realize
  • end

26
Button Widget Event Handler
  • pro beeper_event, event
  • print,"Beep",string(7B)
  • end
  • pro beeper
  • baseWidget_Base( column1, title"Beep" )
  • buttonWidget_Button(base,value"Press Here")
  • Widget_Control, base, /realize
  • Xmanager, 'beeper', base, event_handler'beeper_
    event'
  • end

27
If Your Widget Program Crashes
  • First type
  • IDLgt RETALL
  • Followed by
  • IDLgt XMANAGER
  • You may then edit and recompile as necessary

28
Analyzing the Beep Event Handler
  • You can strategically put help and print commands
    in beep_event and beep to study the values of the
    variables and the resulting structures.
  • When pressed, the word Beep should print out in
    the IDL command window.

29
Beep Counter
  • Let us modify the event handler to count the
    number of times we depressed the button during a
    session
  • An initial solution might be the following

30
Wrong Beep Counter
  • pro beeper_event, event
  • count count 1
  • print,Beeped , count, Times
  • end
  • pro beeper
  • baseWidget_Base(column1, title"Beep")
  • buttonWidget_Button(base,value"Press Here")
  • Widget_Control, base, /realize
  • Xmanager, 'beeper', base, event_handler'beeper_
    event'
  • end

31
It Does Not Work Because...
  • The scope of most of the variables (e.g. count)
    are local to each of the routines.
  • We need a mechanism to maintain, pass, and keep
    variables persistent across events and routines.
  • This can be done using the uvalue of a given
    widget as in the following.

32
Working Beep Counter
  • pro beeper_event, event
  • Widget_Control,event.id,get_uvaluecount
  • count count 1
  • print,"Beeped ", count, " Times"
  • Widget_Control,event.id,set_uvaluecount
  • end
  • pro beeper
  • base Widget_Base( column1, title"Beep" )
  • button Widget_Button( base, value"Press
    Here" )
  • Widget_Control, base, /realize
  • Widget_Control,button,set_uvalue0
  • Xmanager, 'beeper', base, event_handler'beeper_
    event'
  • end

33
An Improved Beep Counter
  • pro beeper_event, event
  • Widget_Control, event.id, get_uvaluecount
  • count count 1
  • Widget_Control, event.id, set_uvaluecount
  • Widget_Control, event.id, set_valuestring(coun
    t)
  • end
  • pro beeper
  • base Widget_Base( column1, title"Beep" )
  • button Widget_Button( base, value"Press
    Here" )
  • Widget_Control, base, /realize
  • Widget_Control, button, set_uvalue0
  • Xmanager, 'beeper', base, event_handler'beeper_
    event'
  • end

34
Beep Counter Controlling a Text Widget
  • pro beeper_event, event
  • Widget_Control, event.id, get_uvaluecount
  • count count 1
  • Widget_Control, event.id, set_uvaluecount
  • Widget_Control, event.top, get_uvaluewidget_id
  • Widget_Control, widget_id, set_valuestring(coun
    t)
  • end
  • pro beeper
  • base Widget_Base( column1, title"Beep" )
  • button Widget_Button( base, value"Press
    Here" )
  • text Widget_Text( base )
  • Widget_Control, base, /realize
  • Widget_Control, base, set_uvaluetext
  • Widget_Control, button, set_uvalue0
  • Xmanager, 'beeper', base, event_handler'beeper_
    event'
  • end

35
Beeper Counter using Text Widget
  • In this situation, we use the uvalue of the base
    widget as a container to hold the ID of the text
    widget.
  • We can now access this information from any
    widget that is contained in this base through the
    event.top field

36
Slider Multiply Example
  • Create two floating sliders and multiply the
    values and deposit this in a text widget.
  • Make the floating point widgets editable

37
Slider Multiply Widget Definition
  • pro fslider_multiply
  • baseWidget_Base(column1)
  • fslider1 CW_Fslider(base,/edit)
  • fslider2 CW_Fslider( base,/edit )
  • text Widget_Text( base )
  • Widget_Control, base, /realize
  • widget_ids slider1fslider1,
    slider2fslider2, texttext
  • Widget_Control, base, set_uvaluewidget_ids
  • end

38
Slider Multiply Event Handler Definition
  • pro fslider_multiply
  • baseWidget_Base(column1)
  • fslider1 CW_Fslider(base,/edit)
  • fslider2 CW_Fslider( base,/edit )
  • text Widget_Text( base )
  • Widget_Control, base, /realize
  • widget_ids slider1fslider1,
    slider2fslider2, texttext
  • Widget_Control, base, set_uvaluewidget_ids
  • Xmanager, 'fslider_multiply', base,
    event_handler'fslider_multiply_event'
  • end

39
Slider Multiply Event Handler Definition
  • pro fslider_multiply_event, event
  • Widget_Control, event.top, get_uvaluewidgets
  • slider1 widgets.slider1
  • slider2 widgets.slider2
  • text widgets.text
  • Widget_Control, slider1, get_valueslider1_value
  • Widget_Control, slider2, get_valueslider2_value
  • answer slider1_value slider2_value
  • Widget_Control, text, set_valuestring(answer)
  • end

40
Another Widget Example
41
Display PGM Widget Program
  • Illustrates the use of the pickfile function
  • Shows how to create a draw widget for image
    display
  • Shows how to access the draw widget and display
    the image

42
Components of Display PGM Widget
  • read_pgm procedure
  • pickfile function
  • size function
  • wset procedure
  • tv procedure
  • widget_control procedure
  • widget_draw function
  • xmanager procedure

43
Display PGM Widget Definition
  • pro simple_image_display
  • base Widget_Base( column1 )
  • button1Widget_Button(base,value'Display PGM
    Image')
  • window1 Widget_Draw(base, xsize256,
    ysize256 )
  • Widget_Control, window1, /realize
  • Widget_Control, window1, get_valuewindow_id
  • Widget_Control, base, set_uvaluewindow_id
  • Xmanager, 'simple_image_display', base,
    Event_handler'simple_image_display_event'
  • end

44
Display PGM Widget
45
Widget Event Handler
  • pro simple_image_display_event, event
  • widget_control, event.id, get_valuewidget_value
  • case widget_value of
  • 'Display PGM Image' begin
  • image1_file pickfile()
  • read_ppm, image1_file, image1_data
  • image_size size( image1_data )
  • x_size image_size( 1 )
    y_sizeimage_size(2)
  • widget_control, event.top,
    get_uvaluewindow_id
  • wset, window_id tv,image1_data
  • end
  • ELSE
  • endcase
  • end

46
Pickfile Dialog Box
47
Resulting Widget Image Display
48
Summary
  • Quit Button
  • Beep Counter
  • Slider Multiply
  • PGM Display
Write a Comment
User Comments (0)
About PowerShow.com