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
| function jpeg2avi(filename)
% JPEG2AVI
% create avi-movie from single frames (jpeg-images)
% Author: P. Knott, 06 May 2004
% frames/images:
aviobj = avifile('C:\Program Files\MATLAB\R2006b\work\CSD\MoviesData\temp.avi','compression','none');
%Images location
fpath = dir(fullfile('C:', 'Program Files', 'MATLAB', 'R2006b', 'work', 'CSD', 'MoviesData',filename, 'CSD'));
imglist= dir(fullfile(fpath,'frame*.jpeg')); % edit path/filename to match your images' location
% default-parameters:
fps= 15; % frames per second
fname = dir(fullfile('C:', 'Program Files', 'MATLAB', 'R2006b', 'work', 'CSD', 'MoviesData',filename, '.avi')); % path/name of movie output file
% create movie:
for k = 1:length(imglist);
[img cmap] = imread([fpath imglist(k).name]);% get current frame
m(k)= im2frame(img, cmap);
if rem(k, 100) == 0
disp([num2str(k) ' frames processed...'])
end
end
aviobj = addframe(aviobj,m);
aviobj=close(aviobj);
% create avi:
movie2avi(m, fname, 'compression', 'None');
% play result:
movie(m, 1, fps); |
Partager