i have a folder with jpg images and i want to convert them into a movie but i also want to have axes on the movie (images dont have axes).my images are grayscale.i ve done something but it is incorrect. the command movie(F,1); shows the movie but the axes are not fix on the movie .also the avi that i save shows only the movie (motion of the images) without the axes. this is my code:
vidObj = VideoWriter('sample.avi');
open(vidObj);
for num_frame=1:40
%find filename of the image
filename = sprintf('%s_%d.jpg','new_image/sample_image',num_frame);
cmap = colormap(gray);
res = grs2rgb(filename,cmap);%convert image from grayscale to rgb
F(num_frame)=im2frame(res);
end
imshow('new_image/sample_image_1.jpg');%show the first image
set(gca,'FontSize',14);
xlabel('Lateral distance [mm]');
ylabel('Axial distance [mm]');
xlim([-50 50]);
ylim([20 105]);
axis([-50 50 20 105]);
axis ('on');
movie(F,1);
writeVideo(vidObj,F);
close(vidObj);
what is the mistake??
The problem is that the axis setup you are doing is only used in MATLAB and is not saved with the video. To save the axis setup, you can use
getframe
to create a new frame of the current plot. I suggest the following:Note the
for num_frame=40:-1:1
: This is to preallocateF
at the first iteration, which is better for speed (MATLAB doesn't need to extend the variable at each iteration)