Btw, my OS is windows 2000, and I use matlab 6.5.0R13.
Thanks and your clue is highly appeciated!
Allen
Why don't you show a snippet of your code to let us see how you're updating
your image and how you're calling getframe?
Brett
Assume fn is the cell array of image filenames
for i=1:size(fn, 1)
im = imread(fn{i});
h=figure; imshow(im);
text(100, 100, num2str(i));
mov(i) = getframe(h);
close;
end;
movie2avi(mov,'test.avi', 'compression', 'indeo5');
The reason for me to use imshow is because I want to put text
annotations on the image. If we only deal with image data, we may use
im2frame without any problem.
Now if you switch windows, some frame might capture the content in the
active window.
Thanks!
Allen
Allen,
First, do you really need to create a new figure for each image you display?
Far better, in most cases, to do something like:
h = figure;
ax = axes;
image = imshow(imread(fn{ii}));
for ii=1:size(fn,1)
set(image,'cdata', imread(fn{ii}));
text(100,100, num2str(ii))
mov = addframe(mov,getframe(image));
end
Cheers,
Brett
Even better is to avoid the use of getframe at all (it causes problems
when the figure is partly occluded):
[...]
mov = addframe(mov, h);
[...]
If you use addframe like this it is even possible to make the figure
invisible.
-Herbert
Nice, Herbert! Didn't know you could do that.
Brett
Allen
mov_file = avifile(handles.mov_name);
mov_fig = figure('visible','off');
mov_axs = axes;
colormap(gray);
set(mov_fig,'DoubleBuffer','on');
imagesc(pix,'parent',movie_axs);
movie_file = addframe(mov_file,mov_fig);
instead of:
imagesc(pix)
F = getframe(gca);
movie_file = addframe(mov_file,F);
The movies run in the background, BUT there is the gray border around
the movie and the axes are labeled. This is not there when I use
getframe and display the figure. Is there anyway to remove this gray
border, axis labels..etc and NOT display the figure?
Note that in the first code you're capturing the figure and putting it in
the AVI file, while in the second code you're capturing the axis and putting
it in the AVI file. The gray border in the first movie is the figure
background that's located outside the axes. Try passing the axis handle to
the call to ADDFRAME in the first case, or try changing the axes Units
and/or Position properties to cause the axes to fill the entire figure.
--
Steve Lord
sl...@mathworks.com
That still does not seem to work, I get almost the exact same thing
when using:
mov_file = avifile(handles.mov_name);
mov_fig = figure('visible','off');
mov_axs = axes;
colormap(gray);
set(mov_fig,'DoubleBuffer','on');
imagesc(pix,'parent',movie_axs);
movie_file = addframe(mov_file,mov_axs);
anyone?
Since you are displaying an image you might consider using
subplot('position', [0 0 1 1]), axis off, and truesize to show only the
image data.
-Herbert