Skip to content

Commit

Permalink
Update frame_sample.m
Browse files Browse the repository at this point in the history
  • Loading branch information
JinghaoLu committed Mar 25, 2022
1 parent ce0e1f1 commit 2621f7f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions utilities/elements/frame_sample.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
function [se, spatialr] = frame_sample(m)
f = imfinfo(m);
n = length(f);
if contains(m, 'tif') || contains(m, 'tiff')
f = imfinfo(m);
n = length(f);
elseif contains(m, 'avi')
f = VideoReader;
n = floor(f.FrameRate * f.Duration);
elseif contains(m, 'mat')
f = matfile(m);
[pixh, pixw, n] = size(f.frame_all);
end
nu = min(100, n);
s = cell(1, nu);
id = randsample(n, nu);
for i = 1: nu
tmp = double(imread(m, id(i)));
if contains(m, 'tif') || contains(m, 'tiff')
tmp = double(imread(m, id(i)));
elseif contains(m, 'avi')
tmp = double(read(f, id(i)));
elseif contains(m, 'mat')
tmp = double(m.frame_all(1: pixh, 1: pixw, id(i)));
end
st = auto_detect_params(tmp);
s{i} = st;
end
Expand Down

0 comments on commit 2621f7f

Please sign in to comment.