-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie.m
92 lines (67 loc) · 2.28 KB
/
movie.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
classdef movie < img
% MOVIE class methods inherited by stm_mv and mv_list:
properties
fps = 20; % frames per seconds
end
properties (Dependent = true, SetAccess = protected, Abstract = true)
mv_name
end
methods
function mv = movie( fps)
if nargin>=1&&~isempty(fps); mv.fps = fps; end
end
function out = merge_tex(self,homogeniousobj)
% merge tex in an array of movie objects.
if nargin<2
homogeniousobj = 0;
end
fprintf('movie: merge_tex, fps of all elements in the input object should be same')
%this will work if elements in the input object vector are same subclass
if homogeniousobj
out = cat(3,self.tex);
else
% this will work if siz of all obj elements are same:
tex_ary = cell(1,numel(self));
for i = 1: numel(self)
tex_ary{i} = self(i).tex;
end
out = cat(3,tex_ary{:});
end
end
function show(self,tex)
if nargin<2
tex = cat(3, self.tex);
end
if iscell(tex)
for i = 1:numel(tex)
implay(tex{i}/(self.max_tex - self.min_tex), self.fps)
end
else
implay(tex/(self.max_tex - self.min_tex), self.fps)
end
end
function save_merge_tex(self, mv_name)
if nargin<2
mv_name = 'merge.mv';
end
merge_text = self.merge_tex;
save_mv(merge_text, mv_name)
end
function save(self)
self.save_tex;
end
end
methods (Access = protected)
function save_tex(self, start_ind)
if nargin<2
start_ind = 1;
end
% tex in each element will be saved in an individual mv file
output_path = self.output_dir;
tx = self.tex;
fname = self.mv_name;
name_ind = sprintf('%03d_',start_ind);
save_mv(tx, [name_ind, fname], output_path);
end
end
end