Matlab and movies

8.10.09

Animations of how 2D matrixes change over time can sometimes be helpful in detecting trends. Bellow is a small bit of code, very trivial, that converts a set of 2D matrixes to a avi movie.

% Images = set of 2D matrixes that we want to convert to a movie (values range from 0-255)
% Frames = Pseudo RGB version Frames
% Mov = Matlab structure that holds the movie
Width = 48; Height = 48;
NumberOfFrames = size(Images, 2);
Frames = zeros([Width, Height, 3, NumberOfFrames]);
for i=1:NumberOfFrames,
Frames(:,:,1,i) = Images{i};
Frames(:,:,2,i) = Images{i};
Frames(:,:,3,i) = Images{i};
end
Mov = immovie(Frames);
movie2avi(Mov, 'movie.avi');