-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_KenburnsObj.m
61 lines (49 loc) · 1.33 KB
/
demo_KenburnsObj.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
% Written by Leon van der Graaff
% Copyright (c) 2018 by the author. Some rights reserved, see LICENCE.
%% Minimal working example
Image = imread('cameraman.tif');
videoWriter = VideoWriter('kenburns','MPEG-4');
KenBurns = KenburnsObj(videoWriter, Image);
% Demo
clf;
KenBurns.image();
KenBurns.plot();
% write
KenBurns.make();
%% Color image
Image = imread('autumn.tif');
videoWriter = VideoWriter('kenburns_color','MPEG-4');
KenBurns = KenburnsObj(videoWriter, Image);
% Demo
clf;
KenBurns.image();
KenBurns.plot();
% write
KenBurns.make();
%% Demonstration of options
Image = imread('cameraman.tif');
videoWriter = VideoWriter('kenburns_options','MPEG-4');
videoWriter.FrameRate = 25;
KenBurns = KenburnsObj(videoWriter, Image);
KenBurns.frameSize = [256 256]; % [height width]
KenBurns.duration = 2; % [s]
KenBurns.startRect = [1 1 1]; % x, y, scale
KenBurns.endRect = [50 10 .7]; % x, y, scale
KenBurns.translation = KenBurns.translationLin;
% demo
clf;
KenBurns.image();
KenBurns.plot();
% write
KenBurns.make();
%% Chaining of transition effects
Image = imread('cameraman.tif');
videoWriter = VideoWriter('kenburns_chained','MPEG-4');
KenBurns = KenburnsObj(videoWriter, Image);
KenBurns.translation = @(t) KenBurns.translationCos(KenBurns.translationBackForth(t));
% demo
clf;
KenBurns.image();
KenBurns.plot();
% write
KenBurns.make();