/
filters.m
38 lines (29 loc) · 1.37 KB
/
filters.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function filters()
import stage.core.*;
% Open a window in windowed-mode and create a canvas. 'disableDwm' = false for demo only!
window = Window([640, 480], false);
canvas = Canvas(window, 'disableDwm', false);
% Get the full path of the Demos/Movies directory.
moviesDir = fullfile(fileparts(mfilename('fullpath')), 'Movies');
% Create a movie stimulus.
boxingMovie = stage.builtin.stimuli.Movie(fullfile(moviesDir, 'boxing.mpg'));
boxingMovie.size = [320, 240];
boxingMovie.position = canvas.size / 2;
% Create an edge-emphasizing filter. The fspecial() function may also be used to create kernel matrices if the Image
% Processing Toolbox is available.
kernel = [-1 -1 -1; ...
-1 8 -1; ...
-1 -1 -1];
filter = Filter(kernel);
% Assign the filter to the movie stimulus.
boxingMovie.setFilter(filter);
% Set the stimulus s (i.e. x) and t (i.e. y) coordinate wrap mode to determine the filter's edge handling.
boxingMovie.setWrapModeS(GL.MIRRORED_REPEAT);
boxingMovie.setWrapModeT(GL.MIRRORED_REPEAT);
% Create a 12 second presentation and add the stimulus.
presentation = Presentation(12);
presentation.addStimulus(boxingMovie);
% Play the presentation on the canvas!
presentation.play(canvas);
% Window automatically closes when the window object is deleted.
end