Video downsampling loop taking too long

1 回表示 (過去 30 日間)
Pavlov
Pavlov 2015 年 2 月 19 日
Hey guys,
I just re-tooled a loop I use to downsample movies. I used to just downsample in one spatial dimension, and am now downsampling in two spatial dimensions as well as in time, so I'm puzzled as to why this is now taking forever where it didn't used to. I'm hoping there's something stupid I am doing in the loop that I can't see...
% spatial downsample, factor of two
ds_factor = 2;
MovieInfo.ds_factor = ds_factor;
% temporal downsample to 15 Hz
ds_factor2 = Vid.FrameRate / 15;
MovieInfo.ds_factor12 = ds_factor2;
imageData = double(read(Vid,1));
%frame_ds = downsample(imageData,ds_factor);
mov = zeros(size(imageData,1)/ds_factor,size(imageData,2)/ds_factor, ...
length(2:ds_factor2:nFrames));
tic
multiWaitbar('Extracting video frames...',0);
count = 0;
for frame = 2:ds_factor2:nFrames
count = count + 1;
imageData = double(read(Vid,frame));
%downsample
Ds = downsample(imageData(:,:,1),ds_factor);
Ds = Ds(:,1:size(Ds,2)/size(mov,2):end);
mov(:,:,count) = Ds;
%mov(:,:,frame) = downsample(imageData(:,:,1),ds_factor);
multiWaitbar('Extracting video frames...', count/length(2:ds_factor2:nFrames));
end
multiWaitbar('Extracting video frames...', 'Close');
toc

回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by