Path: news.mathworks.com!not-for-mail
From: "Scott " <no@spam.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Efficient method to make a movie from a set of images
Date: Sat, 22 Dec 2007 18:15:58 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 58
Message-ID: <fkjk8u$sbj$1@fred.mathworks.com>
References: <c9e5a834-8d3c-4b14-8df2-9fb2be9927bc@v4g2000hsf.googlegroups.com>
Reply-To: "Scott " <no@spam.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1198347358 29043 172.30.248.38 (22 Dec 2007 18:15:58 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 22 Dec 2007 18:15:58 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869596
Xref: news.mathworks.com comp.soft-sys.matlab:443379


Raj <rajanikanth@gmail.com> wrote in message <c9e5a834-8d3c-
4b14-8df2-9fb2be9927bc@v4g2000hsf.googlegroups.com>...
> Hi!
> 
> Could somebody tell me what is the efficient way to make 
a movie from
> a set of images in Matlab?
> 
> Thanks,
> 
> Raj

Raj,

Here is a short movie creation demo. It requires 
mpgwrite.dll which is available in the file exchange. Just 
drop mgpwrite.dll into the directory where you are creating 
movies:

% create some image data
[X Y Z] = sphere(25);
sz = size(Z);
C = rand(sz(1),sz(2),3);

% stitch data to wrap color around sphere
C(:,end,:) = C(:,1,:);

% render an image
figure('color',[0 0 0]);
sp = surf(X,Y,Z,C,'FaceColor','interp',...
    'FaceLighting','phong');
material shiny
axis off vis3d
cl = camlight('right');
camzoom(1.5)
set(sp,'edgecolor','none');
drawnow

% setup the rotation vector for the movie
view_vect_yaw = [-180:3:180];
sz_vect = size(view_vect_yaw);

% "lights, camera, action!"
for f = 1:sz_vect(2)
    % set the view, reset light position and render
    view([view_vect_yaw(f) 15]);
    camlight(cl,'right')
    drawnow
    % grab a frame
    m(f) = getframe(gcf);
end
% format frames as mpeg and write to file
mpgwrite(m,C,'my_movie.mpg',...
    [1, 0, 1, 0, 10, 1, 1, 1]);
% end of code

hth,
Scott