
COMP 116
November 12, 2007
Assn #7: Change blindness, Due Nov 30
In this assignment, the amount of code you have to write is small, but it has to interact
with MATLAB's mechanisms for user interfaces.
Write a program that will allow you to experiment with the parameters of change
blindness, as demonstrated by Rensink et al. http://www.psych.ubc.ca/~rensink/flicker/
What timings make change detection hard? Are some changes easier to detect than others? Are
some people consistently take longer than others? Do people learn as they see more examples?
Your program should take a list of pairs of images, and put the pairs in random order.
Then it will give a user 60 or 120 seconds to detect the change in each pair by showing each
image for a chosen amount of time (say 0.5, 1, 1.5, or 2.5 seconds) , followed by a gray, black, or
white screen for a chosen amount of time (say 0, 0.08, 0.1, 0.15, 0.25 secs). The user presses a
key when they detect the change, and the program records the time with the experimental
parameters (including chosen times, image, & image order) and maybe some user parameters
(gender, age, tiredness) which you can ask for.
To break this into smaller pieces:
1. Start a timer…
The timer is easy: tic; starts the timer and t = toc; sets t to the number of seconds between
tic and toc. (Without the semicolon, toc will print the time.)
2. …that you can read when a key on the keyboard is pressed.
More interesting is to get MATLAB to respond when a key is pressed, even if it is busy doing
other things – this is the issue faced by any GUI (Graphical User Interface). MATLAB (and many
other systems that support GUIs, including Java, Visual Basic/C++, and .NET) use callback
functions; small functions that you write, and then register with the system so that they are called
on some user interface event (key or button press, mouse click or drag, etc.)
If you write the following function myfig:
function myfig(src,evnt)
% callback function for keypress in figure window
clf; toc % clear figure & display time since tic
And then type the following in MATLAB:
figure('KeyPressFcn',@myfig); imagesc(magic(8)); tic;
Then when you press a key, MATLAB will blank the figure and print the time.
Global variables (see doc global): I’ve mentioned these before saying I didn’t want to teach them,
but now is the time… You can have a variable foo that can be accessed by several functions if at
the top of your script and each function you say global foo. This is to be avoided if possible,
but sometimes you need a callback function to set something like gKeyPressed = true; to indicate
that a key has been pressed.
3. Show images…
For most images, you just x = imread(filename); image(x); axis image; (axis image
makes each pixel square on the screen.)