-
Notifications
You must be signed in to change notification settings - Fork 1
/
rit_videoload.m
68 lines (67 loc) · 2.66 KB
/
rit_videoload.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
function [video, fps, nframes] = rit_videoload(video_file, colormode)
%% HELP
%
% Copyright 2020-2021 Ivana Labounkova(1,2), Rene Labounek(2), Igor Nestrasil(2,3),
% Jan Odstrcilik(1), Ralf P. Tornow(4), Radim Kolar(1)
% (1) Department of Biomedical Engineering, Brno University of Technology, Brno, Czech Republic
% (2) Division of Clinical Behavioral Neuroscience, Department of Pediatrics, University of Minnesota, Minneapolis, USA
% (3) Center for Magnetic Resonance Research, Department of Radiology, University of Minnesota, Minneapolis, USA
% (4) Department of Ophthalmology, Friedrich-Alexander University of Erlangen-Nuremberg, Erlangen, Germany
%
% This file is part of Retina Imaging Toolbox available at: https://github.com/ivanalabounkova/retinaimagingtoolbox
%
% Retina Imaging Toolbox is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or any later version.
%
% Retina Imaging Toolbox is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Retina Imaging Toolbox. If not, see <https://www.gnu.org/licenses/>.
%
% Papers related to specific RIT functions are listed in the cite_papers.txt file.
%%
v = VideoReader(video_file);
if size(double(readFrame(v)),3) == 1
colormode = 'r';
end
v = VideoReader(video_file);
ind = 1;
switch colormode
case {'r', 'g', 'b'}
switch colormode
case 'r'
channel = 1;
case 'g'
channel = 2;
case 'b'
channel = 3;
end
while hasFrame(v)
frame = im2double(readFrame(v));
video(:,:,ind) = frame(:,:,channel);
ind = ind + 1;
end
case 'gray'
while hasFrame(v)
frame = im2double(readFrame(v));
video(:,:,ind) = rgb2gray(frame);
ind = ind + 1;
end
case 'rgb'
while hasFrame(v)
frame = readFrame(v);
video(:,:,:,ind) = frame;
ind = ind + 1;
end
end
fps = v.FrameRate;
if strcmp(colormode,'rgb')
nframes = size(video,4);
else
nframes = size(video,3);
end
end